[英]Mustache render() over an array not working
我在這里做錯了什么?
<!doctype html>
<html>
<head>
<title>Testing</title>
<script src="mustache.js"></script>
</head>
<body>
<script type="text/javascript">
var musk = ["athos", "porthos", "some other guy"];
var output = Mustache.render("<div>The three <br>{{#musk}}<p>{{.}}</p>{{/musk}}<br> Those guys</div>", musk);
console.log(output);
</script>
</body>
</html>
這給我:
<div>The three <br><br> Those guys</div>
如果我沒記錯的話,我幾乎是從github頁面復制示例。 另外,我很確定模板中允許使用html,但不允許在內容或視圖中使用html。 對?
您需要這樣命名輸入數組:
var musk = {musk: ["athos", "porthos", "some other guy"]};
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.