Mason.FluentHtml is a simple, unambitious library for building HTML documents in a fluent manner.
using Mason.FluentHtml;
HtmlBuilder htmlBuilder = new HtmlBuilder();
htmlBuilder.Table(new { @class = "table-primary" }, table =>
{
table.Tbody(tbody =>
{
tbody.Tr(tr =>
{
tr.Td(td => td.Content("Cell 1"));
tr.Td(td => td.Content("Cell 2"));
});
});
});
string html = htmlBuilder.ToString(); //<table class="table-primary"><tbody><tr><td>Cell 1</td><td>Cell 2</td></tr></tbody></table>
This example shows how to use Mason.FluentHtml to build a basic HTML table.
- Fluent Interface: Build HTML documents with a natural and intuitive syntax.
- No Dependencies: The library has no external dependencies and is designed to be lightweight.
- Target Framework: Mason.FluentHtml targets .NET Standard 2.0, ensuring compatibility across various platforms.
To install Mason.FluentHtml, you can use the following NuGet command:
dotnet add package Mason.FluentHtml
Mason.FluentHtml is licensed under the GNU General Public License v3.0.