我正在尝试将javascript对象传递给handlebars模板。但是,我收到错误:Uncaught ReferenceError: Handlebars is not defined
。但是,我安装了快速把手,把手模板在我通过路线传递数据的页面上正常工作。这是我的模板:
<body>
<div id="render_here">
first placeholder
</div>
<div id="render_here_again">
second placeholder
<div>
<script id="first-template" type="text/x-handlebars-template">
<div>
<h1 style="color:green">{{title}}</h1>
<h2 style="color:red">{{body}}</h2>
</div>
</script>
<script type="text/javascript" src="javascript/templating.js"></script>
</body>
这是我的.js文件:
$(document).ready(function() {
var source = $('#first-template').html();
var template = Handlebars.compile(source);
var context = {
title: "All about handlebars",
body: "body body body"
};
var el_html = template(context);
$("#render_here").html(el_html)
$('#render_here_again').html(el_html)
});
我安装了快速把手包。有人可以帮忙吗?
谢谢!