JSFiddle - React, Tailwind, and code Playground

by Matt Ball

HTML

<script src="https://github.com/janl/mustache.js/raw/master/mustache.js"></script>

JavaScript

var template = '<select>{{#options}}' +
                   '<option value="{{val}}" {{#sel}}selected{{/sel}}>' + 
                       '{{txt}}' + 
                   '</option>' + 
               '{{/options}}</select>',
               
    data = {options: [
        {val: 1, txt: 'uno'},
        {val: 2, txt: 'dos'},
        {val: 3, txt: 'tres', sel: true}
    ]};
    
var html = Mustache.to_html(template, data);

$(html).appendTo('body');