Reusing steering wheel templates

I am new to JS and Handlebars templates. I have a nested JSON structure, often each parent node is a new object / has a different structure, so recursion is not the solution that I think.

My question is: Is it possible to call another template from a template in Handlebars?

My background XSLT

Example:

<script id="entry-template" type="text/x-handlebars-template"> <div>{{name}}</div> .. call template-2 </script> <script id="template-2" type="text/x-handlebars-template"> <div>{{name2}}</div> .. call template-3 </script> <script id="template-3" type="text/x-handlebars-template"> <div>{{name3}}</div> </script> 

.. etc.

Anyone who has any tips?

Regards, Bob

+4
source share
2 answers

This should be pretty easy with the help of partials, but here is a pretty good tutorial .

Essentially, although you just need to define a partial

  Handlebars.registerPartial("template-2", $("#template-2").html()); 

And then use it

 <script id="entry-template" type="text/x-handlebars-template"> <div>{{name}}</div> {{> template-2}} </script> 
+6
source

I created a youtube video on particles that explain this: https://www.youtube.com/embed/02J5A3r-Bdk . The video explains the creation of steering scores in detail, and some problems and problems that come long and when they are best used and when the server side can be better.

0
source

Source: https://habr.com/ru/post/1445862/


All Articles