A fast, NativeAOT-compatible library for writing minified HTML with C#. Although the output is not forever guaranteed to be valid XHTML, it currently is.
ASP.NET does not currently support native compilation for Razor Pages.
We offer two styles of using the library:
//Fluent API
new Img(writer).WithSrc("www.example.com").Close();
using (new A(writer).WithClass("btn").End())
{
//Inner content
}
//Initialization API
new Img(writer) { Src = "www.example.com" }.Close();
using (new A(writer) { Class = "btn" }.End())
{
//Inner content
}
These two methods are required to conclude an html element constructor call. End
is for normal elements, and Close
is for self-closed elements.