@ryan.murray
To render a plain array with Mustache.js, you can use a template that loops through each item in the array and renders it. Here's an example:
1 2 3 |
const data = { items: ['apple', 'banana', 'orange'] }; |
1 2 3 4 5 6 7 |
<script id="template" type="text/html"> <ul> {{#items}} <li>{{.}}</li> {{/items}} </ul> </script> |
1 2 3 |
const template = document.getElementById('template').innerHTML; const rendered = Mustache.render(template, data); document.getElementById('output').innerHTML = rendered; |
1
|
<div id="output"></div> |
When you run this code, it will iterate over the items array and render each item as a list item in an unordered list. The final output will look like this:
This is a simple example of how to render a plain array with Mustache.js. You can customize the template and data to fit your specific needs.