Chinajiniannet/jntemplate
jntemplate is an fast and lightweight html templating engine for C# .NET.
JNTemplate
What is JNTemplate?
JNTemplate is fast, lightweight, extensible .net template engine for generating html, xml, sql, or any other formatted text output.
Special placeholders in the template allow writing code similar to c# syntax. Then the template is passed data to render the final document.
Installation
Install and update using NuGet:
PM> Install-Package JinianNet.JNTemplate
or
> dotnet add package JinianNet.JNTemplate
Quickstart
Basics
Rendering a basic html template with a predefined data model.
c# code
var template = Engine.LoadTemplate(@"c:\wwwroot\view\index.html"); ;
template.Set("name", "jntemplate");
var result = template.Render();
index.html
<h1>Hello, ${name}</h1>
output:
<h1>Hello, jntemplate</h1>
Iteration
Iteration is achieved by using the foreach binding on the element you wish to iterate.
c# code
var template = Engine.LoadTemplate(@"c:\wwwroot\view\view.html"); ;
template.Set("list", new string[] { "github","jntemplate" });
var result = template.Render();
view.html
<ul>
${foreach(name in list)}
<li>${name}</li>
${end}
</ul>
output:
<ul>
<li>github</li>
<li>jntemplate</li>
</ul>
Configuration
You can configure JNTemplate with the IOptions class.
Engine.Configure((options)=>{
// .. configure your instance
});
Links
- Website: https://www.jiniannet.com
- Documentation: https://docs-en.jiniannet.com
- Code: https://github.com/jiniannet/jntemplate
Licenses
MIT
Similar Projects
Discover other similar projects and AI models.
The fastest template library/engine for building web-based user interfaces and apps.
Jinja2 C++ (and for C++) almost full-conformance template engine implementation
The most popular HTML, CSS, and JavaScript framework for developing responsive, mobile first projects on the web.
A fast, powerful, safe and lightweight scripting language and engine for .NET
.NET project templates with batteries included, providing the minimum amount of code required to get you going faster.