hogan.js具有主页面或布局 [英] hogan.js with master pages or layouts

查看:133
本文介绍了hogan.js具有主页面或布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能以任何方式使用hogan.js作为模板引擎,其布局类似于
Razor或.NET中的母版页?
我会得到这样的结果:

Is it possible in any way to use hogan.js as template engine with layouts something like "Razor or master pages in .NET"? I would get a result like this:

layout.hjs:
包含header& footer

layout.hjs: contains "header" & "footer"

index.hjs:
将包含layout.hjs并仅包含页面内容

index.hjs: will include layout.hjs and contain only page content.

推荐答案

确定:

layout.hjs: / p>

layout.hjs:

{{> header}}
{{$content}}
  default content
{{/content}}
{{> footer}}

index.hjs:

index.hjs:

{{<layout}}
  {{$content}}
    your content goes here
  {{/content}}
{{/layout}}

查看所有可以做的全部测试文件:
< a href =https://github.com/twitter/hogan.js/blob/master/test/index.js> https://github.com/twitter/hogan.js/blob/master/test/index .js

see the hogan test file for all it can do: https://github.com/twitter/hogan.js/blob/master/test/index.js

btw。这是Hogan@3.0.0,使用带有mpn的git url获取它

btw. this is Hogan@3.0.0, get it with a git url with mpn

这篇关于hogan.js具有主页面或布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆