代码拉取完成,页面将自动刷新
JntemplateViewEngine是基于Jntemplate的ASP.NET MVC视图引擎,简单来说它可以让你在ASP.NET MVC中更方便的使用Jntemplate.
Jntemplate源码可以从下面的地址获取
GITEE(国内):https://gitee.com/jiniannet/jntemplate GITHUB:https://github.com/jiniannet/jntemplate
Jntemplate 文档:http://docs.jiniannet.com/
Startup.cs
,在ConfigureServices方法中增加AddJntemplateViewEngine
,如下如示 public void ConfigureServices(IServiceCollection services)
{
//...其它代码
//Add Jntemplate ViewEngine
services.AddJntemplateViewEngine();
}
Configure
方法中增加UseJntemplate
,如下如示 public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
//...其它代码
//Use Jntemplate
app.UseJntemplate(jntemplateConfig =>
{
//在这里你也可以进行其它参数的配置
jntemplateConfig.ContentRootPath = env.ContentRootPath;
});
}
在Views\Home下增加一个Index.html 或者Index.jnt 内容如下:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>${Site.Name}</title>
</head>
<body>
<h1>Welcome to ${Site.Name}!</h1>
<p>Engine Version:${Site.Version} ©${Now.Year}</p>
</body>
</html>
打开HomeController,增加一个Index的Action
public IActionResult Index()
{
this.Set("Site", new SiteViewModel
{
Name = "Jntemplate",
Version = JinianNet.JNTemplate.Engine.Version
});
this.Set("Now", DateTime.Now);
return View();
}
具体可参考演示项目JntemplateViewEngineDemo
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。