JSFiddle - React, Tailwind, and code Playground
HTML
<ns tmp="red"></ns>
<ns tmp="blue"></ns>
<ns tmp="green"></ns>
JavaScript
var template_functions = {
blue: function(){
return "hi malli";
},
red:function(){
return "welcome";
}
};
(function($){
/*This retrieves all the custom tags and gets the template
property to point to.*/
var templateArray=$('ns');
template_functions.green = function(){return 'asdf';};
templateArray.each(function(){
var template=$(this).attr('tmp');
alert(template_functions[template]());
});
})(jQuery);