JSFiddle - React, Tailwind, and code Playground

by sathyamoorthi

HTML

<script src="http://cdnjs.cloudflare.com/ajax/libs/handlebars.js/1.0.0/handlebars.min.js"></script>

<script id="test-template" type="text/x-handlebars-template">
  <label>Label here</label>
{{textField dataAttribs='{"text":"Hello", "class":"input"}'}}
</script>

JavaScript

Handlebars.registerHelper('textField', function(options) {
    var dom = '<input type="text">', attribs;
    
    attribs = JSON.parse(options.hash.dataAttribs);
    console.log(attribs.text + " -- " + attribs.class);
    
    return new Handlebars.SafeString(dom);
});

$(function() {

    var markup = $('#test-template').html();
    var template = Handlebars.compile(markup);
    $('body').append(template());

});