Block form component

I’m attempting my first plugin and have come across this in the codebase:

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

I’ve done some basic Ember recently, but haven’t come across the {{#name}} syntax yet.

I learnt to use components like (without the hash in the name):

{{component-name}}

Does the hash/pound symbol represent anything special? Is it even a component? And why is the categoryPageStyle component being called with ‘component’ in front of it?

Thanks!

Yes, and the # denotes block form (instead of inline)

3 Likes

Thanks for your help @cpradio

I’m also assuming that components can exist without having their own template file? (As there doesn’t appear to be one for discovery-categories.)

This is something I was also unaware of!

Yes, it depends how the component is built and what it is extending (if anything).

Example of using Buffered Render
https://github.com/cpradio/discourse-plugin-composer-help-button/blob/master/assets/javascripts/discourse/components/composer-help-content.js.es6

Versus one that is utilizing a template
https://github.com/cpradio/discourse-plugin-imgflip/blob/master/assets/javascripts/discourse/components/imgflip-result.js.es6

2 Likes