Do you know of any others? Feel free to leave a comment below. Thanks!
HtmlTags - https://github.com/HtmlTags/htmltags
- Developed by Jimmy Bogard, same guy behind AutoMapper.
- Downside for some: quite verbose
- Downside: Resulting HTML is not pretty printed. See issue: HtmlTags/htmltags#116
- Actively maintained
Example:
new HtmlTag("html").Append(new[] {
new HtmlTag("head")
.Append(new HtmlTag("title").Text("Abc")),
new HtmlTag("body")
.Append(new HtmlTag("h1").Text("People"))
.Append(
new HtmlTag("table")
.Append(
new HtmlTag("thead").Append(new []{
new HtmlTag("th").Text("Name"),
new HtmlTag("th").Text("Birth date"),
new HtmlTag("th").Text("Height"),
}))
.Append(
new HtmlTag("tbody").Append(People().Select(person =>
new HtmlTag("tr")
.Append(new HtmlTag("td").Text(person.Name))
.Append(new HtmlTag("td").Text(person.BirthDate))
.Append(new HtmlTag("td").Text(person.Height.ToString()))))))
.Append(new HtmlTag("div").AddClass("abc").Text("xyz"))
.Append(new HtmlTag("div").AddClass("a b c d").Text("bcd"))
.Append(new HtmlTag("a").Attr("href", "https://www.gnu.org").Text("GNU"))
})
hyperlinq - https://github.com/hyperlinq/hyperlinq
- Developed by Ben Albahari, author of C# in a Nutshell
- Very concise
- Output is pretty printed
- Not frequently updated (minor patch in 2019, last major update in 2014)
Example:
H.html(
H.head(H.title("bcd")),
H.body(
H.h1("People"),
H.table(
H.thead(
H.th("Name"),
H.th("Birth date"),
H.th("Height")),
H.tbody(
People().Select(person => H.tr(
H.td(person.Name),
H.td(person.BirthDate),
H.td(person.Height))))),
H.div(a => a.Custom("class", "abc"), "xyz"),
H.div(a => a.css("a b c d"), "bcd"),
H.a(attrs => attrs.href("https://www.gnu.org"), "GNU"))
)