![](/img/trans.png)
[英]Failed to lookup view “index” in views directory | Express | HBS instead of handlebars.js
[英]hbs rendered site with handlebars.js in the script - nodejs
我使用hbs渲染頁面,其中包含用於導航和頁腳的部分內容。
router.get('/test', function (req, res) {
return res.render('test');
});
在一頁上,我有使用mustache.js的模板。 該模板無法正常工作,因為{{}}似乎是在hbs渲染器上拾取的。 下面是一個說明該錯誤的基本示例。 如果使用express將其加載為靜態頁面,則會顯示“ Joe is a Web Developer”,如果使用hbs呈現它,則會顯示“ is a”。
是否有任何變通辦法不涉及我更改所有頁面的呈現方式?
<!doctype html>
<html lang="en">
<head>
<title>Mustache.js Inline Method</title>
<script type="text/javascript" src="js/libs/mustache.js" ></script>
<script>
var view = {
name : "Joe",
occupation : "Web Developer"
};
function loadtemp(){
var output = Mustache.render("{{name}} is a {{occupation}}", view);
document.getElementById('person').innerHTML = output;
}
</script>
</head>
<body onload="loadtemp()" >
<p id="person"></p>
</body>
</html>
這很簡單。 我只需要用\\括住括號即可。
\{{name}}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.