[英]Including other template files in Handlbars
我有一个index.html文件,我正在使用它作为基本文件。 然后,我想将网站的各个部分分成较小的文件,以包含在我的基本文件中。 我正在尝试通过导航菜单执行此操作。 我正在使用browserify包含模板文件。
index.html
<body>
<div id="nav-template"></div>
</body>
导航把手
<script id="nav-template" type="text/x-handlebars-template">
<p>This Is A Nav</p>
</script>
然后,我运行把手nav.handlebars -f templates.js
app.js
var $ = require('jquery');
var Handlebars = require('handlebars');
var templates = require('./templates');
var template = Handlebars.templates['nav-template']
var html = template();
$('#nav-template').html(html);
我的浏览器什么也没有,也没有错误。
nav.handlebars应该是:
<p>This Is A Nav</p>
使用外部处理程序栏文件时无需script
标记
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.