Ember template convention


(megas) #1

I’m trying to understand EmberJS template convention in Discourse.
Here’s a snippet from app/assets/javascripts/discourse/templates/discovery/categories.hbs

{{#discovery-categories refresh="refresh"}}
  {{component controller.categoryPageStyle
              categories=model.categories
              latestTopicOnly=controller.latestTopicOnly
              topics=model.topics}}
  {{!-- my-template --}}
{{/discovery-categories}}

What is the meaning of discovery-categories and component?
For example I want to insert my-template to extend categories.hbs, what is the convention I should use to create file with template?


(Régis Hanol) #2

discovery-categories is this component. It’s used to display categories in the home pages.

component is an Ember helper which allows to insert components dynamically :wink:


(megas) #3

Could you explain more explicitly? What is the block style {{#d}}…{{/d}}?


(Régis Hanol) #4

That’s the block syntax in handlebars.

I suggest you go through the handlebars doc and the Ember Guides to learn more.