" tag After

Confusion over "data-template-name" and "id" in "<script>" tag

After <script type="text/x-handlebars"

a. I am wondering in which cases I put data-template-name and in which cases I put id .

In the reference source of the video, they use id exclusively.

In the todomvc source and almost everywhere I've seen, data-template-name .

b. And what exactly is put after data-template-name and id (i.e. What happens after them = )?

+6
source share
2 answers

a) AFAIK id is a new version of data-template-name , and they seem to work the same way.

b) id allows you to identify the template in your routing, rendering or "views".

For routing: You can use this name to help the router determine which template to render, for example. use this.render('displayStuff) during renderTemplate in the route to β€œoverride” the default template for the route.

See also: http://emberjs.com/guides/routing/rendering-a-template/

For rendering: Templates allow you to use certain ways to change the rendering. Ember-Handlebars provides {{render}} and {{partial}} to change the default template associated with the view.

See also: http://emberjs.com/guides/templates/rendering-with-helpers/

For views: By default, the view will find the appropriate template based on the agreement. So somethingView has an associated somethingController and something template template (therefore a template with id='something' ). The view will also allow you to abandon this agreement by setting its templateName parameter.

See also: http://emberjs.com/guides/views/inserting-views-in-templates/

hope this helps!

+2
source
+1
source

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


All Articles