Textpattern CMS support forum
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" />
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.
Re: Using flat js for Modules
Aye, that would work. Didn’t think of tag-as-attribute, thank you.
<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.