javascript - How does the helper {{templatePath}} work? -


<template name="postitem">   <div class="post">     <div class="post-content">       <h3><a href="{{url}}">{{title}}</a><span>{{domain}}</span></h3>     </div>     <a href="{{postpagepath this}}" class="discuss btn">discuss</a>   </div> </template> 

this returns absolute url. postpage template defined. automatically gets helper path? don't understand how {{templatepath}} returns.

in handlebars.js define helpers in javascript in way:

handlebars.registerhelper('helpername', function(argument) {     // ... perform actions here     return whatever; // return here }); 

you use helper in way: {{helpername something}}. something there argument or arguments want pass helper. arguments come context working in. 'context' referring json data pass handlebars fill template.

your helper takes data , builds it. could, example, concatenate string argument in way: var whatever = "<p>" + argument.value1 + "</p>" , returns result, gets pushed page (return whatever).

the handlebars using global object defined handlebars.js this. used if want compile templates: included methods of global object.

i hope of you.


Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -