小胡子render()在数组不工作

Cos*_*sta 1 javascript templates mustache

我在这做错了什么?

<!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>
Run Code Online (Sandbox Code Playgroud)

这给了我:

<div>The three <br><br> Those guys</div>
Run Code Online (Sandbox Code Playgroud)

如果我没有弄错的话,我几乎完全从github页面复制了这个例子.此外,我很确定模板内部允许使用html,而不是内容或视图内部.对?

eba*_*axt 5

您需要像这样命名输入数组:

var musk = {musk: ["athos", "porthos", "some other guy"]};
Run Code Online (Sandbox Code Playgroud)