JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/mustache.js/2.1.3/mustache.js"></script>
<script type="text/template" id="field-template">
<!-- read this for an explanation of how text/template works: http://www.codereadability.com/constructing-html-with-templates/ -->
{{#formFields}}
<div class="form-field">
<label>{{title}}</label>
<input type="text" name="{{name}}"></input>
</div>
{{/formFields}}
</script>
CSS
body {
padding: 50px;
}
.form-field label{
width: 100px;
display: inline-block;
}
JavaScript
var formFields = [{
title: "First Name",
name: "firstName"
},
{
title: "Last Name",
name: "lastName"
},
{
title: "City",
name: "city"
},
{
title: "Country",
name: "country"
}];
var template = document.getElementById("field-template").innerHTML;
document.body.innerHTML = Mustache.render(template, {formFields: formFields});