【发布时间】:2017-02-01 03:04:45
【问题描述】:
如何使用布局、带有把手模板的部分,如下所示?
我查看了 partial 文档,但仍然无法弄清楚我想要实现的目标。
default.html
默认布局可重复用于网站的不同视图。 {{{content}}} 用作将呈现主要内容的占位符。
<!DOCTYPE html>
<html>
<head>
<title>{{title}}</title>
</head>
<body>
<p>This is the top of the body content in the default.html file</p>
{{{content}}}
<p>This is the bottom of the body content in the default.html file</p>
</body>
</html>
index.html
{{#> default}}
{{ include header }}
<p>This is some other content</p>
{{ include footer }}
header.html
<h1>This is a header</h1>
footer.html
<p>This is a footer</p>
输出
<!DOCTYPE html>
<html>
<head>
<title>Using Layout, Partials with Handlebars Template</title>
</head>
<body>
<p>This is the top of the body content in the default.html file</p>
<h1>This is a header</h1>
<p>This is some other content</p>
<p>This is a footer</p>
<p>This is the bottom of the body content in the default.html file</p>
</body>
</html>
【问题讨论】:
-
@AndreyEtumyan。我已经更新了我的问题。
标签: javascript html handlebars.js template-engine template-inheritance