简体   繁体   中英

Mustache render() over an array not working

What am I doing wrong here?

<!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>

This give me:

<div>The three <br><br> Those guys</div>

If I'm not mistaken, I'm copying the example from the github page almost identically. Also, I'm pretty sure html is allowed inside the template, just not inside the content or view. Right?

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

var musk = {musk: ["athos", "porthos", "some other guy"]};

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM