Blockhelp

From rbachwiki
Jump to navigation Jump to search
<script id="content" type="text/x-handlebars-template">
{{#makeRadio "size"}}
small
medium
large
{{/makeRadio}}
</script>

Javascript

templateInfo = $('#content').html();
template = Handlebars.compile(templateInfo);
Handlebars.registerHelper("makeRadio", function(name, options){
 var radioList = options.fn();
radioList = radioList.trip().split("\n");

var output = "";
for(var val in radioList){
 var item = radioList[val].trim();
output += '<input type="radio" name="'+ name + '"value="' + item + '">' + item + '<br />';
}
return output;
// create blank template data
var templateData = template({});
$('#content').html() = templateData;
})


Back To Top< — > Handlebars Category< — > Java Script Category<--> Home