/// <summary> /// Opens a <c><tbody></c> block after first closing the existing /// <c><thead></c> block opened by a previous call to /// <see cref="TableHead(FluentRenderTreeBuilder, string?, string?, string?, int)">TableHead(...)</see>. /// </summary> /// <param name="frtb">The <see cref="FluentRenderTreeBuilder"/>.</param> /// <param name="line">The source code line number used to generate the sequence number.</param> public static FluentRenderTreeBuilder OpenTableBody(this FluentRenderTreeBuilder frtb, [CallerLineNumber] int line = 0) => frtb .Close(line: line) // table-head .OpenElement("tbody", null, null, line: line) .CloseHelper(l => frtb.Close(2, line: l)); // tr, thead
/// <summary> /// Calls <see cref="FluentRenderTreeBuilder.Close(bool, int)">Close(...)</see> with the /// <c>prettyPrint</c> parameter set to <c>false</c>, to generate markup to close the /// last opened <c>Region</c>, <c>Element</c> or <c>Component</c> block without any /// newline or indent whitespace, even if pretty-printing is enabled (see the /// <see cref="FluentRenderTreeBuilder"/> overview for details on pretty-printing). /// </summary> /// <param name="frtb">The <see cref="FluentRenderTreeBuilder"/>.</param> /// <param name="line">The source code line number used to generate the sequence number.</param> public static FluentRenderTreeBuilder CloseInline(this FluentRenderTreeBuilder frtb, [CallerLineNumber] int line = 0) => frtb.Close(prettyPrint: false, line);
/// <summary> /// Opens a new <c><tr></c> block, adding the given CSS class attribute if provided, /// after first closing the currently open row. /// </summary> /// <remarks> /// Note: Do not use this method with an /// <see cref="OpenAutoTable(FluentRenderTreeBuilder, string?, string?, string?, int)">OpenAutoTable(...)</see>; /// instead, use <see cref="NewAutoRow(FluentRenderTreeBuilder, string?, int)">NewAutoRow(...)</see>. /// </remarks> /// <param name="frtb">The <see cref="FluentRenderTreeBuilder"/>.</param> /// <param name="class">The optional CSS class name for the new table row.</param> /// <param name="line">The source code line number used to generate the sequence number.</param> public static FluentRenderTreeBuilder NewRow(this FluentRenderTreeBuilder frtb, string? @class = null, [CallerLineNumber] int line = 0) => frtb .Close(line: line) // tr .OpenRow(@class, line);
/// <summary> /// Generates a <c><p></c> block containing a component of the given type, adding /// the given id and CSS class attributes to the <c><p></c> and setting its key, /// if provided. /// </summary> /// <remarks> /// Note: This block is automatically closed, so calling /// <see cref="FluentRenderTreeBuilder.Close(bool, int)">Close(...)</see> is unnecessary. /// </remarks> /// <param name="frtb">The <see cref="FluentRenderTreeBuilder"/>.</param> /// <param name="type">The <see cref="Type"/> of the component to add.</param> /// <param name="class">The optional CSS class name.</param> /// <param name="id">The optional id attribute value.</param> /// <param name="key">The optional key to set for this element.</param> /// <param name="prettyPrint"><c>false</c> to prevent insertion of newline and indent /// whitespace before the markup for this element, even if /// <see cref="FluentRenderTreeBuilder.PrettyPrinting"/> is enabled.</param> /// <param name="line">The source code line number used to generate the sequence number.</param> public static FluentRenderTreeBuilder ComponentP(this FluentRenderTreeBuilder frtb, Type type, string? @class = null, string?id = null, object?key = null, bool prettyPrint = true, [CallerLineNumber] int line = 0) => frtb.ComponentElement("p", type, @class, id, key, prettyPrint, line);
/// <summary> /// Generates a <c><p></c> block containing a component of the specified type, /// adding the given id and CSS class attributes to the <c><p></c> and setting its /// key, if provided. /// </summary> /// <remarks> /// Note: This block is automatically closed, so calling /// <see cref="FluentRenderTreeBuilder.Close(bool, int)">Close(...)</see> is unnecessary. /// </remarks> /// <typeparam name="TComponent">The <see cref="Type"/> of the component to add.</typeparam> /// <param name="frtb">The <see cref="FluentRenderTreeBuilder"/>.</param> /// <param name="class">The optional CSS class name.</param> /// <param name="id">The optional id attribute value.</param> /// <param name="key">The optional key to set for this element.</param> /// <param name="prettyPrint"><c>false</c> to prevent insertion of newline and indent /// whitespace before the markup for this element, even if /// <see cref="FluentRenderTreeBuilder.PrettyPrinting"/> is enabled.</param> /// <param name="line">The source code line number used to generate the sequence number.</param> public static FluentRenderTreeBuilder ComponentP <TComponent>(this FluentRenderTreeBuilder frtb, string? @class = null, string?id = null, object?key = null, bool prettyPrint = true, [CallerLineNumber] int line = 0) where TComponent : IComponent => frtb.ComponentElement <TComponent>("p", @class, id, key, prettyPrint, line);
/// <summary> /// Generates a <c><td></c> block containing the given markup, adding the given CSS /// class attribute, and setting the key, if provided. /// </summary> /// <param name="frtb">The <see cref="FluentRenderTreeBuilder"/>.</param> /// <param name="markup">The markup content to add in the <c><td></c> block.</param> /// <param name="class">The optional CSS class name.</param> /// <param name="key">The optional key to set for this table cell.</param> /// <param name="line">The source code line number used to generate the sequence number.</param> public static FluentRenderTreeBuilder Cell(this FluentRenderTreeBuilder frtb, object markup, string? @class = null, object?key = null, [CallerLineNumber] int line = 0) => frtb.Element("td", markup, @class, key: key, line: line);
/// <summary> /// Opens a new <c><li></c> block within a /// <see cref="OpenList(FluentRenderTreeBuilder, string?, string?, int)">OpenList(...)</see> or an /// <see cref="OpenOrderedList(FluentRenderTreeBuilder, string?, string?, int)">OpenOrderedList(...)</see>, /// adding the given CSS class attribute, and setting /// the key, if provided, after first closing the currently open item. /// </summary> /// <remarks> /// Note: Do not use this method within an /// <see cref="OpenAutoList(FluentRenderTreeBuilder, string?, string?, string?, object?, int)"> /// OpenAutoList(...)</see> or an /// <see cref="OpenAutoOrderedList(FluentRenderTreeBuilder, string?, string?, string?, object?, int)"> /// OpenAutoOrderedList(...)</see>; /// instead, use <see cref="NewAutoItem(FluentRenderTreeBuilder, string?, object?, int)"> /// NewAutoItem(...)</see>. /// </remarks> /// <param name="frtb">The <see cref="FluentRenderTreeBuilder"/>.</param> /// <param name="class">The optional CSS class name for the new list item.</param> /// <param name="key">The optional key to set for this list item.</param> /// <param name="line">The source code line number used to generate the sequence number.</param> public static FluentRenderTreeBuilder NewItem(this FluentRenderTreeBuilder frtb, string? @class = null, object?key = null, [CallerLineNumber] int line = 0) => frtb .Close(line: line) // li .OpenItem(@class, key, line);
/// <summary> /// Adds a <c>data-[name]</c> attribute. /// </summary> /// <param name="frtb"></param> /// <param name="name">The data value name.</param> /// <param name="value">The data value.</param> /// <param name="line">The source code line number used to generate the sequence number.</param> public static FluentRenderTreeBuilder Data(this FluentRenderTreeBuilder frtb, string?name, object value, [CallerLineNumber] int line = 0) => string.IsNullOrEmpty(name) ? frtb : frtb.Attribute($"data-{name}", value, line);
/// <summary> /// Generates a heading block containing the given markup, adding the given id and CSS /// class attributes to the heading, if provided. /// </summary> /// <remarks> /// Note: This block is automatically closed, so calling /// <see cref="FluentRenderTreeBuilder.Close(bool, int)">Close(...)</see> is unnecessary. /// </remarks> /// <param name="frtb">The <see cref="FluentRenderTreeBuilder"/>.</param> /// <param name="level">The heading level, e.g. <c>1</c>, <c>2</c>, <c>3</c>, etc.</param> /// <param name="markup">The markup content to add in the heading block.</param> /// <param name="class">The optional CSS class name.</param> /// <param name="id">The optional id attribute value.</param> /// <param name="line">The source code line number used to generate the sequence number.</param> public static FluentRenderTreeBuilder Heading(this FluentRenderTreeBuilder frtb, int level, object markup, string? @class = null, string?id = null, [CallerLineNumber] int line = 0) => frtb.Element($"h{level}", markup, @class, id, line: line);
/// <summary> /// Adds a CSS <c>class</c> attribute. /// </summary> /// <remarks> /// Passing in a null or empty <paramref name="name"/> results in no attribute being generated. /// </remarks> /// <param name="frtb">The <see cref="FluentRenderTreeBuilder"/>.</param> /// <param name="name">The class name.</param> /// <param name="line">The source code line number used to generate the sequence number.</param> public static FluentRenderTreeBuilder Class(this FluentRenderTreeBuilder frtb, string?name, [CallerLineNumber] int line = 0) => string.IsNullOrEmpty(name) ? frtb : frtb.Attribute("class", name, line);
/// <summary> /// Adds an <c>id</c> attribute. /// </summary> /// <remarks> /// Passing in a null or empty <paramref name="value"/> results in no attribute being generated. /// </remarks> /// <param name="frtb">The <see cref="FluentRenderTreeBuilder"/>.</param> /// <param name="value">The id value.</param> /// <param name="line">The source code line number used to generate the sequence number.</param> public static FluentRenderTreeBuilder Id(this FluentRenderTreeBuilder frtb, string?value, [CallerLineNumber] int line = 0) => string.IsNullOrEmpty(value) ? frtb : frtb.Attribute("id", value, line);
/// <summary> /// Generates a <c><div></c> block containing the given content, adding the given id /// and CSS class attributes to the <c><div></c> and setting its key, if provided. /// </summary> /// <remarks> /// Note: This block is automatically closed, so calling /// <see cref="FluentRenderTreeBuilder.Close(bool, int)">Close(...)</see> is unnecessary. /// </remarks> /// <param name="frtb">The <see cref="FluentRenderTreeBuilder"/>.</param> /// <param name="fragment">The <see cref="RenderFragment"/> to add.</param> /// <param name="class">The optional CSS class name.</param> /// <param name="id">The optional id attribute value.</param> /// <param name="key">The optional key to set for this element.</param> /// <param name="prettyPrint"><c>false</c> to prevent insertion of newline and indent /// whitespace before the markup for this element, even if /// <see cref="FluentRenderTreeBuilder.PrettyPrinting"/> is enabled.</param> /// <param name="line">The source code line number used to generate the sequence number.</param> public static FluentRenderTreeBuilder ContentDiv(this FluentRenderTreeBuilder frtb, RenderFragment fragment, string? @class = null, string?id = null, object?key = null, bool prettyPrint = true, [CallerLineNumber] int line = 0) => frtb.ContentElement("div", fragment, @class, id, key, prettyPrint, line);
/// <summary> /// Generates a <c><div></c> block containing the given markup, adding the given id /// and CSS class attributes to the <c><div></c> and setting its key, if provided. /// </summary> /// <param name="frtb">The <see cref="FluentRenderTreeBuilder"/>.</param> /// <param name="markup">The markup content to add in the <c><div></c> block.</param> /// <param name="class">The optional CSS class name.</param> /// <param name="id">The optional id attribute value.</param> /// <param name="key">The optional key to set for this element.</param> /// <param name="prettyPrint"><c>false</c> to prevent insertion of newline and indent /// whitespace before the markup for this element, even if /// <see cref="FluentRenderTreeBuilder.PrettyPrinting"/> is enabled.</param> /// <param name="line">The source code line number used to generate the sequence number.</param> public static FluentRenderTreeBuilder Div(this FluentRenderTreeBuilder frtb, object markup, string? @class = null, string?id = null, object?key = null, bool prettyPrint = true, [CallerLineNumber] int line = 0) => frtb.Element("div", markup, @class, id, key, prettyPrint, line);
.CloseHelper(l => frtb.Close(2, line: l)); // li, ul /// <summary> /// Opens a <c><ol></c> block, adding the given id and CSS class attributes if /// provided. /// </summary> /// <remarks> /// Note: Each call to this method must be matched with a call to /// <see cref="FluentRenderTreeBuilder.Close(int, bool, int)">Close(...)</see>. /// </remarks> /// <param name="frtb">The <see cref="FluentRenderTreeBuilder"/>.</param> /// <param name="class">The optional CSS class name for the list.</param> /// <param name="id">The optional id attribute value.</param> /// <param name="line">The source code line number used to generate the sequence number.</param> public static FluentRenderTreeBuilder OpenOrderedList(this FluentRenderTreeBuilder frtb, string? @class = null, string?id = null, [CallerLineNumber] int line = 0) => frtb.OpenElement("ol", @class, id, line: line);
/// <summary> /// Opens a <c><table></c> block, adding the given id and CSS class attributes if /// provided. /// </summary> /// <remarks> /// Note: Each call to this method must be matched with a call to /// <see cref="FluentRenderTreeBuilder.Close(int, bool, int)">Close(...)</see>. /// </remarks> /// <param name="frtb">The <see cref="FluentRenderTreeBuilder"/>.</param> /// <param name="class">The optional CSS class name for the table.</param> /// <param name="id">The optional id attribute value.</param> /// <param name="line">The source code line number used to generate the sequence number.</param> public static FluentRenderTreeBuilder OpenTable(this FluentRenderTreeBuilder frtb, string? @class = "table", string?id = null, [CallerLineNumber] int line = 0) => frtb.OpenElement("table", @class, id, line: line);
/// <summary> /// Generates an <c><h6></c> block containing the given markup, adding the given id /// and CSS class attributes to the heading, if provided. /// </summary> /// <remarks> /// Note: This block is automatically closed, so calling /// <see cref="FluentRenderTreeBuilder.Close(bool, int)">Close(...)</see> is unnecessary. /// </remarks> /// <param name="frtb">The <see cref="FluentRenderTreeBuilder"/>.</param> /// <param name="markup">The markup content to add in the <c><h6></c> block.</param> /// <param name="class">The optional CSS class name.</param> /// <param name="id">The optional id attribute value.</param> /// <param name="line">The source code line number used to generate the sequence number.</param> public static FluentRenderTreeBuilder H6(this FluentRenderTreeBuilder frtb, object markup, string? @class = null, string?id = null, [CallerLineNumber] int line = 0) => frtb.Heading(6, markup, @class, id, line);
.CloseHelper(l => frtb.Close(2, line: l)); // tr, table /// <summary> /// Opens a <c><tr></c> block, adding the given CSS class attribute if provided. /// </summary> /// <remarks> /// Note: Each call to this method must be matched with a call to /// <see cref="FluentRenderTreeBuilder.Close(int, bool, int)">Close(...)</see>. /// </remarks> /// <param name="frtb">The <see cref="FluentRenderTreeBuilder"/>.</param> /// <param name="class">The optional CSS class name for the table row.</param> /// <param name="line">The source code line number used to generate the sequence number.</param> public static FluentRenderTreeBuilder OpenRow(this FluentRenderTreeBuilder frtb, string? @class = null, [CallerLineNumber] int line = 0) => frtb.OpenElement("tr", @class, line: line);
/// <summary> /// Generates a <c><br></c> element. /// </summary> /// <param name="frtb">The <see cref="FluentRenderTreeBuilder"/>.</param> /// <param name="prettyPrint"><c>false</c> to prevent insertion of newline and indent /// whitespace before the markup for this element, even if /// <see cref="FluentRenderTreeBuilder.PrettyPrinting"/> is enabled.</param> /// <param name="line">The source code line number used to generate the sequence number.</param> public static FluentRenderTreeBuilder Break(this FluentRenderTreeBuilder frtb, bool prettyPrint = true, [CallerLineNumber] int line = 0) => frtb.Markup("<br />", prettyPrint, line);
/// <summary> /// Generates a <see cref="NavLink"/> component, adding the given href, Match, CSS class /// (defaulting to "nav-link") and ActiveClass attributes, if given; then adding a /// <c>ChildContent</c> attribute for the given markup text. /// </summary> /// <param name="fluentBuilder"></param> /// <param name="href"></param> /// <param name="markup"></param> /// <param name="class"></param> /// <param name="activeClass"></param> /// <returns></returns> public static FluentRenderTreeBuilder NavLink(this FluentRenderTreeBuilder fluentBuilder, string href, string markup, string? @class = null, string?activeClass = null) => fluentBuilder .OpenComponent <NavLink> (@class ?? "nav-link") .MultipleAttributes(new (string, object)[]
.CloseHelper(l => frtb.Close(2, line: l)); // li, ol /// <summary> /// Opens an <c><li></c> block, adding the given CSS class attribute, and setting /// the key, if provided. /// </summary> /// <remarks> /// Note: Each call to this method must be matched with a call to /// <see cref="FluentRenderTreeBuilder.Close(int, bool, int)">Close(...)</see>. /// </remarks> /// <param name="frtb">The <see cref="FluentRenderTreeBuilder"/>.</param> /// <param name="class">The optional CSS class name.</param> /// <param name="key">The optional key to set for this list item.</param> /// <param name="line">The source code line number used to generate the sequence number.</param> public static FluentRenderTreeBuilder OpenItem(this FluentRenderTreeBuilder frtb, string? @class = null, object?key = null, [CallerLineNumber] int line = 0) => frtb.OpenElement("li", @class, null, key: key, line: line);