-
Notifications
You must be signed in to change notification settings - Fork 0
Home
chrcar01 edited this page Sep 13, 2010
·
7 revisions
A well documented Fluent .NET API for creating html.
Download the assembly from the downloads page. Reference it in your project. Make sure to import the HtmlBuilder namespace and you’re ready to go.
new Element("p").Update("Hello World");
// <p>Hello World</p>
new Element("span","style=font-weight:bold;width=200px;class=sooper;")
// <span width="200px" style="font-weight:bold;" class="sooper"></span>
new Element("span",
new Element("b").Update("Hello"));
// <span><b>Hello</b></span>
new Element("b").Update("hello") + "<i>bye bye</i>";
// <b>hello</b><i>bye bye</i>
public string GetSomeHtml(){
return new Element("p").Update("Here's some html");
}
string html = GetSomeHtml();
// <p>Here's some html</p>
string path = @"C:\htmlbuilder-test.html";
using (FileStream file = new FileStream(path, FileMode.CreateNew))
{
new Element("html",
new Element("body",
new Element("h1").Update("Hello World")
)
).Render(file);
}