riot-js

Open full view…

Declare nested tag file inside parent tag file?

greenlaw110
Sun, 15 May 2016 08:33:59 GMT

It looks like I have to declare all tag files in the main html file like: ```javascript <script type="riot/tag" src="parent.tag.html"></script> <script type="riot/tag" src="child.tag.html"></script> ``` If I add the `child.tag.html` declaration inside the `parent.tag.html` file then it will not load. See this plunker: http://plnkr.co/edit/JTS1ELxkdko2n9akzOeb?p=preview In side the plunker app, I have defined a parent tag, and two child tag: child_a and child_b, however I load child_a inside the main html, while declare child_b inside the parent tag, and the result is child a get displayed but child b is not there at all

crisward
Thu, 02 Jun 2016 22:20:10 GMT

Looks like child b isn't being loaded. [Screen Shot 2016-06-02 at 23](//muut.com/u/riot-js/s3/:riot-js:xpT4:screenshot20160602at23.19.33.png.jpg)

jhfoo
Wed, 07 Jun 2017 03:55:36 GMT

Were you able to solve the problem? I'm also looking at keeping nested tags in separate files.

jonaspm
Sat, 10 Jun 2017 06:10:48 GMT

Why not just declare on index.html ?

jonaspm
Sat, 10 Jun 2017 07:26:24 GMT

I somewhat managed to accomplish what you deserved: Using fetch() & FileReader though is not the best solution... But at least works with your example. https://plnkr.co/edit/doNiLG1mPaN92cm4pWv4?p=preview

jonaspm
Sat, 10 Jun 2017 07:50:40 GMT

Sorry, this is the correct Plunker: https://plnkr.co/edit/CoQg2u4aqYPGb5O1XKM1?p=preview I realized that javascript scripts inside child_b won't work with this solution. However, If you only need static content, this may be enough :)

jonaspm
Sat, 10 Jun 2017 08:00:18 GMT

What I do when developing apps with Riot.js is to compile all tags into one single components.js file (with Riot CLI) and then mount the parent tag.

jhfoo
Sat, 10 Jun 2017 20:08:43 GMT

@jonaspm have you tried multiple compiled files and lazy-load them as needed (eg. via a new route)?

jonaspm
Sun, 11 Jun 2017 17:31:44 GMT

Hmm no, but recently I was reading a blog post about something similar using SSR https://medium.com/@prateekbh/isomorphic-app-with-riotjs-in-simple-steps-de8a50611dbc I may try to do lazy loading and report results back.

jhfoo
Sun, 11 Jun 2017 17:52:51 GMT

I think I made it work. See https://github.com/jhfoo/tag-lib-loader

jonaspm
Mon, 12 Jun 2017 17:50:59 GMT

Interesting! Give it a try and tell us how it went!