XF 2.1 How to use handlebarsjs on xenforo 2 template

fahad ashraf

Well-known member
Hello,

I want to use http://handlebarsjs.com/ on xenforo 2 template but when i am using below code i am getting template syntax any body please help me


Code:
<script id="tpl-gbs" type="text/x-handlebars-template">
  <ul>
    {{#each gbs}}
       <li data-handle="{{handle}}">{{description}}</li>
    {{/each}}
  </ul>
</script>

I also try below code but still getting error

Code:
<xf:js id="tpl-gbs" type="text/x-handlebars-template">
  <ul>
    {{#each gbs}}
       <li data-handle="{{handle}}">{{description}}</li>
    {{/each}}
  </ul>
</xf:js>
 
XenForo already includes Mustache JS which we would recommend rather than bringing in another library that essentially does the same job.

You will then see support in our existing templates to get around the {{}} issue (look for mustache in templates).
 
XenForo already includes Mustache JS which we would recommend rather than bringing in another library that essentially does the same job.

You will then see support in our existing templates to get around the {{}} issue (look for mustache in templates).
@Chris D thanks for your response can you please guide how i can use same syntax

Code:
  {{#each gbs}}
       <li data-handle="{{handle}}">{{description}}</li>
    {{/each}}

in mustache please

Thanks
 
I've said really all I can say - you can see how we make the double curly braces work in templates using Mustache and then, as far as I know, the overall syntax is very similar - for the Mustache documentation and API you would have to look at their official documentation.
 
Top Bottom