Skip to content
This repository has been archived by the owner. It is now read-only.
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.

README.md

Powerful and extandable HTML generation library in C# using .NET Standard 1.3

using static Nerven.Htmler.Core.HtmlBuilder;

var document = Document(
    htmlTag(
        headTag(
            metaTag(
                charsetAttr(Encoding.UTF8)),
            titleTag(
                Text("Htmler Demo"))),
        bodyTag(
            divTag(
                Comment("makes it easy -- really easy -- to generate HTML correctly and securily --> (look, this comment is properly escaped)"),
                pTag(
                    idAttr("paragraph-with-id"),
                    classAttr("important-paragraph"),
                    Raw("you are wrong and I'm right, this shouldn't be escaped: <<< (while inheretly secure, Htmler doesn't stop when you insist)"),
                    divTag(
                        Text("Supports flag attributes"),
                        inputTag(Attribute("disabled", null)),
                        buttonTag(Attribute("disabled", null))),
                    aTag(
                        imgTag(
                            Attribute("src", "test.png")),
                        spanTag(Text("It's > with escaped text!"))))),
            pTag(
                Text("Well, to avoid issues with whitespace affecting layout, "),
                Text("default mode generates no whitespace or newlines at all, "),
                Text("but one can turn on some newlines if needed.")))));

var s = document.WriteReadableToString();

becomes

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Htmler Demo</title>
</head>
<body>
<div>
<!--makes it easy - - really easy - - to generate HTML correctly and securily - -> (look, this comment is properly escaped)-->
<p id="paragraph-with-id" class="important-paragraph">you are wrong and I'm right, this shouldn't be escaped: <<< (while inheretly secure, Htmler doesn't stop when you insist)
<div>Supports flag attributes
<input disabled>
<button disabled></button>
</div>
<a>
<img src="test.png">
<span>It's &gt; with escaped text!</span>
</a>
</p>
</div>
<p>Well, to avoid issues with whitespace affecting layout, default mode generates no whitespace or newlines at all, but one can turn on some newlines if needed.</p>
</body>
</html>

About

Generate static HTML documents using a powerful API, write a complete site to disk or host it with OWIN (Library, C#/.NET Standard 1.3)

Resources

License

Packages

No packages published
You can’t perform that action at this time.