Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
Using flat js for Modules
Hmmm. Trying to incorporate plyr.io into a site. If I upload all the paraphernalia and 3 million support files into my /themes/theme-name/forms/js
directory and kick the main script off with this:
<txp:output_form form="plyr.js" format="flat.script" />
I get SyntaxError: import declarations may only appear at top level of a module
.
But if I use:
<script type="module" src="/themes/theme-name/forms/js/plyr.js"></script>
Then it loads (albeit that I get warnings in Firefox that it can’t load the modules, which seems to be because the programmer of plyr.io didn’t use imports with full filename including the .js
extension so I need to go through and change them all *sigh*).
Is it possible to load modules using the flat.script
technique? I’m not sure <txp:yield>
variables help me in this situation.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
Re: Using flat js for Modules
Like this?
<script type="module" src="<txp:output_form form="plyr.js" format="flat.url" />"></script>
I don’t think <txp:yield />
would work here, though we could amend it in a future version.
Offline
Re: Using flat js for Modules
Aye, that would work. Didn’t think of tag-as-attribute, thank you.
The <txp:yield />
thing is probably not so important: I think I can get Txp to parse()
the js file so I can inject the tracklist and metadata from the surrounding <txp:file_download_list>
tag via vanilla tags embedded in the script that kicks things off.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
Offline
Re: Using flat js for Modules
Wow, awesome. I’ll give your plugin a whirl too, thank you so much.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
Pages: 1