简体   繁体   中英

Riot.js dynamically render nested custom tags from different files server side

I am trying to make use of riot.js server-side rendering to make a static HTML page that could be read by google spiders. I have a basic example working but I am trying to figure out how to dynamically load tags from different files when rendering on the server.

I understand that if you "require" each tag file it will work, but there should be a way for the system to detect and find what tags are needed from the main tag file.

for instance given this tag stored in "home.tag":

<home>
      <foo></foo>
      <bar></bar>
</home>

when I require "home.tag", I would think there would be a better way to include the "foo.tag" and "bar.tag" files automatically without having to individually require each of them. Any help would be greatly appreciated thanks!

require-all could allow you to just simply require all of the .tag files in a templates directory. It would be convenient for riotjs to just understand which tag files are necessary, but considering the way that node.js and riotjs have to play along with each other, I think it's better off that you have to explicitly require the .tag files. Where would riotjs look for them if you didn't require them yourself? How would it resolve conflicts?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM