Why mixes widget and handlebars?

AI-generated summary

Discussion Summary: Why mixes widget and handlebars?

Chong_An_Chen is seeking clarity on why Discourse combines widgets and Handlebars, finding it complicated and hard to maintain. zogstrip explains that this is a performance-driven decision, a tradeoff for “hot paths” despite the added complexity.

Chong_An_Chen also inquires about interacting with widgets from Ember controllers, having trouble finding a solution. pfaffman suggests searching for “theme howto” for guidance. sam advises exploring existing plugins like the polls plugin and referencing the list of plugins on GitHub (https://github.com/discourse/all-the-plugins) for inspiration.

Hi everyone, I’ve tried to customize our discourse for about a month.

Then I’d like to ask why mixes widget and handlebars together?
I think that makes code more complicated and hard to maintain.

For an example, I want to move Create Topic button to header, then I just realized the button is created in hbs but header is in widget.

I really want to know the reason why you want to combine different things together.
I know for performance issue widget is a good tool, but don’t you think that is harder to trace and revise?

And there is another question: Does anyone know how to trigger event in widget from ember controller?
I’ve been stuck on the confusing architecture for a while..

For performance reasons.

It does, but it’s a tradeoff we are ok to make for our hot paths.

thank you for replying quickly,

Do you know how to interact with widget from ember controller?

I’ve tried A tour of how the Widget (Virtual DOM) code in Discourse works - #57 by eviltrout, but it doesn’t work …

Search for “theme howto”

My advice here would be to look at existing plugins like polls plugin etc.

There is a large list at: GitHub - discourse/all-the-plugins · GitHub