2 Star 2 Fork 0

翅膀的初衷 / JntemplateViewEngine

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

关于JntemplateViewEngine

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/

快速上手

  • 模板使用新后缀.jnt 或者 .html

配置视图引擎

  • 打开 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} &copy;${Now.Year}</p>
</body>
</html>

增加Action

打开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

The MIT License Copyright (c) jiniannet (hnvvv@163.com) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

用于asp.net mvc core的jntemplate视图引擎 展开 收起
C# 等 2 种语言
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
C#
1
https://gitee.com/jiniannet/JntemplateViewEngine.git
git@gitee.com:jiniannet/JntemplateViewEngine.git
jiniannet
JntemplateViewEngine
JntemplateViewEngine
master

搜索帮助