[英]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.