-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
.tag.html extension for server-side rendered tags #57
Comments
Hi Tas12, My solution was to let riot first compile the tag into a .js file, and require that .js file in your server side code. I made a (very basic) proof of concept here: riot-serverside-rendering I don't know if this is the 'official' way to do it, but thats how I got it to work. |
@tas12 Could your issue be similar to this: #6 (comment)? In that case, you probably should omit the |
@petergoes @phortuin thanks for your helpful responses! I also thought of these solutions and went with omitting the .html extension for server-side rendered tags. I guess this would just have to be documented clearly in a readme. For me, pre-compiling would an extra step on top of bundling frontend js and compiling scss files. Is it worth adding a note in the style guide? |
As long as riot does not support custom extensions in server side rendering, I do think it is worth adding it to the guide. |
@tas12 @petergoes @phortuin You can use require.extensions['.tag'] = function(module, filename) {
loadAndCompile(filename, {}, module)
} However, you can also simply use the // instead of
var riot = require('riot')
var timer = require('timer.tag')
// use
var riot = require('riot')
var timer = riot.require('timer.tag.html') @petergoes maybe you can test this and change this in #59, to simply say that if you want to use |
Thank you for sharing this style guide
Is there a way to use the .tag.html extension when using the riot.render() method in the server?
Example from http://riotjs.com/guide/#server-side-rendering:
I would like to 'require' a riot tag with .tag.html ext but this causes an error when starting the server
The text was updated successfully, but these errors were encountered: