Skip to content

C# (.Net) to HTML generator. Enjoy typesafe HTML generation.

License

Notifications You must be signed in to change notification settings

Itay2805/DotNet2HTML

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DotNet2HTML

C# (.Net) to HTML generator. Enjoy typesafe HTML generation.

This project is heavily inspired by j2html.

Getting started

Downlaod from Nuget

Package Manager

PM> Install-Package DotNet2HTML -Version 1.0.1

.NET CLI

> dotnet add package DotNet2HTML --version 1.0.1

Import the TagCreator and start building HTML

using DotNet2HTML.Tags;
using static DotNet2HTML.TagCreator;

namespace Program {  
  class Program {
    public static void Main(string[] args) {
      Body(
        H1("Hello, World!"),
        Img().WithSrc("/img/hello.png")
      ).Render();
    }    
  }
}

The above C# will result in the following HTML:

<body>
    <h1>Hello, World!</h1>
    <img src="/img/hello.png">
</body>