Skip to content

Holoon/HtmlBuilder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HtmlBuilder

HTML

Tool to build an HTML DOM in C# and export it to a string or to an IHtmlContent Enumerable.

Installation

Install-Package Holoon.HtmlBuilder

Nuget package: https://www.nuget.org/packages/Holoon.HtmlBuilder/

Usage

var root = Html.Div();

var h1 = Html.Heading(1);
h1.AddChild(Html.TextBloc("Hello World !"));
root.AddChild(h1);

var paragraph = Html.Paragraph();
var ul = Html.BulletList();
var li = Html.ListItem();
paragraph.AddChild(ul);
ul.AddChild(li);
li.AddChild(Html.TextBloc("This is a first test."));
root.AddChild(paragraph);

root.AddChild(Html.HorizontalRule());

root.AddChild(Html.TextBloc("This is a second test.", new InlineTag("strong", KeyValuePair.Create("class", "second"))));

var html = root.ToString();
/* html:
<div>
    <h1>Hello World !</h1>
    <p>
        <ul>
            <li>This is a first test.</li>
        </ul>
    </p>
    <hr />
    <strong class="second">This is a second test.</strong>
</div>
*/

Contributing

If you'd like to contribute, please fork the repository and use a feature branch. Pull requests are welcome. Please respect existing style in code.

About

Tool to build an HTML DOM in C# and export it to a string or to an IHtmlContent Enumerable.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages