NateDhaliwal is having trouble displaying HTML in a template tag at a specific outlet location using an initializer in a Discourse plugin. merefield suggests using the connectors folder, but NateDhaliwal explains that the reason for using an initializer is to allow selection of different outlets.
merefield points out several issues with the code, including a missing closing bracket, undeclared variables, and missing imports. NateDhaliwal fixes the issues and gets the code working.
david suggests an alternative way to reference the settings object directly from the template, simplifying the code. merefield notes that while .gjs components have improved the developer experience, there are still some odd errors that can occur, such as the “Invalid value used as weak map key” error.
david explains that this error is likely due to Ember optimizations in production builds and recommends developing themes/plugins against a proper development environment. merefield realizes that they can use localhost with the Theme CLI to get better error messages and thanks david for the tip.
david recommends using localhost with a theme-cli and notes that discourse.theme-creator.io runs with development-mode Ember assets, providing nicer error messages.
Yeah, the helper doesn’t work (and isn’t needed) in gjs. Defining a getter is fine. But if you want to avoid that, you can reference the settings “global” directly from the template:
Where did you see the WeakMap error? On a production site? If so… perhaps this is one of the checks which ember optimizes out of production builds to improve performance.
If you can, I’d always recommend developing themes/plugins against a proper development environment - there are lots of cases like this where the experience will be better.
Yes, Production site using the Theme CLI ( which I guess is one of its downsides, despite its otherwise it’s a great workflow?)
That makes total sense.
Yes, with plugins it’s my goto but with TCs there’s a good temptation to dev against a Production site because of the immediacy of feedback (if not always very helpful!)
But I’ve just realised, you can enter localhost with the CLI and it works.
So duh!
I will use that going forward!
I have no idea why I thought that wouldn’t be possible
As usual, thanks for your help that’s saved me a lot of time (in the future )
Yup! Localhost with a theme-cli is how I try to work, and what I recommend to other people. We can definitely do better at documenting these recommended workflows
The other tip is that discourse.theme-creator.io runs with development-mode Ember assets. So that should have the nicer error messages as well.