I'm looking for a way to add a section of JavaScript code to a page that is required for my plugin. I know you can include a file via $this->addJs()
but I need the JavaScript to be dynamically constructed from settings in the plugin's settings model.
I can do this using a {% put scripts %}...{% endput %}
block in my default.htm, but this gets injected multiple times if I use the component multiple times in the page.
Is there a way to inject the code into the page only once, no matter how many times the component is used on the page?