翅膀的初衷 ad096fdb90 unit test ! update
2021-05-22 16:27:02 +08:00
2016-04-12 21:56:21 +08:00
2021-02-03 21:59:19 +08:00
2021-05-22 16:27:02 +08:00
2021-04-06 22:37:04 +08:00
2014-07-25 16:45:24 +08:00
2018-05-10 17:33:10 +08:00
2018-04-24 16:56:12 +08:00
2021-05-22 16:12:54 +08:00
2018-04-28 16:38:35 +08:00
2021-05-19 23:34:25 +08:00
2018-05-08 10:52:57 +08:00
2021-05-22 16:27:02 +08:00
2021-02-03 21:59:19 +08:00
2016-08-30 15:49:21 +08:00
2021-04-08 21:54:41 +08:00
2021-04-08 21:54:41 +08:00

JNTemplate

Build Status GitHub stars GitHub stars GitHub license GitHub issues

English | 中文

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 EngineConfig class.

Engine.Configure((conf)=>{
// .. configure your instance
});

Licenses

MIT

Description
C#开发的高速.NET模板引擎
Readme 6.9 MiB
Languages
C# 96.4%
CSS 1.6%
HTML 1.4%
Batchfile 0.3%
PowerShell 0.2%
Other 0.1%