Skip to content
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

Compile to html for use with Riot.js #47

Closed
brauliobo opened this issue Sep 6, 2015 · 7 comments
Closed

Compile to html for use with Riot.js #47

brauliobo opened this issue Sep 6, 2015 · 7 comments

Comments

@brauliobo
Copy link

I would like to .js.tag.skim files to be compiled to html so that I could use it with Riot as described at http://riotjs.com/guide/compiler/#pre-processors

How could that be done? Maybe a .html.skim sprockets processor?

@gkopylov
Copy link
Contributor

gkopylov commented Sep 6, 2015

You can do it by adding .tag extension to .jst.skim files, so finally extension should be .jst.skim.tag. So that will be handle by jst, skim and tag engines.

@brauliobo
Copy link
Author

@gkopylov Actually it generated javascript not the HTML needed for Riot.

I'm going to generate a simple html using Skim and ExecJs. How can I do server side rendering to HTML? I've tried Skim::Template.new{ 'p' }.render but it only return javascript.

@gkopylov
Copy link
Contributor

gkopylov commented Sep 6, 2015

@brauliobo yeah, you are right, but skim oriented for client side view, so it is compiled to JST template and render it on server side could be a bit tricky(but sure you can do it via ExecJS like it goes here https://github.com/jfirebaugh/skim/blob/master/test/helper.rb ).

For server side view I recommend you to use slim https://github.com/slim-template/slim

@brauliobo
Copy link
Author

thanks @gkopylov, the main goal is to have isomorphic templates, so they can be used on Rails and on the Browser.

I'm trying some workarounds to use Slim, see slim-template/slim#650

@gkopylov
Copy link
Contributor

gkopylov commented Sep 6, 2015

It is very interesting idea and I tried it earlier, but as a final result you will come to different context - in client side you will work with js objects(and then past it on skim template) and on server side you will need to serialize ruby objects and then past it in precompiled skim template, so not that simple and useful. Moreover you need to somehow create DOM on server side to proper work with output html. So I left this idea. But maybe you could do it better so good luck.

@brauliobo
Copy link
Author

@gkopylov About serialization of ruby objects to json, I think this is necessary one way or another, for APIs and dynamic interfaces.

Then, execjs (with therubyracer) can render Riot's .tag files (after slim compilation of .tag.slim) quite simple and fast in my benchmarks.

@gkopylov
Copy link
Contributor

gkopylov commented Sep 6, 2015

Ok, I wish you to get excellent results for isomorphic templates and resolve all issues for this.

Btw, try Turbolinks 3, it is really blazing fast, so you no need to use that hipsterish technology like Virtual dom and etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants