Difference between revisions of "HandlebarsHelpers"

From rbachwiki
Jump to navigation Jump to search
(Created page with "<pre> <script id="content" type="text/x-hanglebars-template"> {{makeLink "Text for Link" "http://www.outwater.com"}} </script> </pre> '''JavaScript''' <pre> Handlebars.registe...")
(No difference)

Revision as of 18:00, 17 January 2017

<script id="content" type="text/x-hanglebars-template">
{{makeLink "Text for Link" "http://www.outwater.com"}}
</script>

JavaScript

Handlebars.registerHelper("makeLink", function(text, url){
text= Handlebars.Utils.escapeExpression(text);
url = Handlebars.Utils.escapeExpression(url);

var theLink = '<a href=" + url + '">' + text + '</a>';
return new Handlebars.SafeString(theLink);
// SafeString does not escape return
});

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