How can I mount a tag that has been pre compiled to a function with riot.js/cli to iife JS version. What am I doing wrong? By getting an empty html DOM as a result.
<html>
<head>
<script type="riot" src="/riot/tag.js"></script>
<script src="/js/riot.js"></script>
<script>
riot.mount('tag');
</script>
</head>
<body>
<tag></tag>
</body></html>
Maybe there is something more I need to do to mount it like a function style? Also tried to register() first. that did not seem to help. Maybe I did it wrong?
riot.register('tag');
Did you try
riot.inject()? That is meant to be used for on-the fly compiling of riot components, but i think it's the step you are missing.Check also the docs for more context: https://riot.js.org/compiler/#in-browser-compilation-with-inline-templates
you compiled it already so you don't need this part:
BUT: you still need to get the compiled string that sits in your linked file at
/riot/tag.js, so you somehow have to fetch that. If you still want to go with that approach (it's 1/2 year later now =D) i would suggest you change thesrcattribute todata-src(so it's not loaded automatically by the browser and handle the fetching of the compiled string yourself, something like this:Below is are the functions from riot+compiler for reference, they are relatively simple: