JSFiddle - React, Tailwind, and code Playground
by prabhat rai
HTML
<script src="http://cdnjs.cloudflare.com/ajax/libs/handlebars.js/2.0.0/handlebars.js"></script>
<script type="text/x-handlebars-template" id="test1">
{{ link_to 'articles'}}
</script>
<div id="test">
</div>
JavaScript
Handlebars.registerHelper('link_to', function(href, title) {
if (!title || typeof title != 'String') {
title = href.toString().charAt(0).toUpperCase() + href.slice(1);
}
return new Handlebars.SafeString('<a href="/' + href + '">' + title + '</a>');
});
html = $('#test1').html();
/* Compile */
template = Handlebars.compile(html);
/* Generate HTML using template */
appendText = template('');
$('#test').html(appendText);