Jntemplate
jntemplate is an fast and lightweight html templating engine for C# .NET.
Install / Use
/learn @jiniannet/JntemplateREADME
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
<!DOCTYPE html>
<html>
<body>
<h1>Hello, ${name}</h1>
</body>
</html>
output:
<!DOCTYPE html>
<html>
<body>
<h1>Hello, jntemplate</h1>
</body>
</html>
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
Related Skills
node-connect
349.9kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
109.8kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
349.9kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
349.9kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
