Question: how about a production-version of Twig.js? #80

Open
rkyoku opened this Issue Apr 28, 2013 · 6 comments

Comments

Projects
None yet
6 participants
@rkyoku

rkyoku commented Apr 28, 2013

Hi,

With Handlebars, one can grab a "production only" version of Handlebars that can only execute pre-compiled templates (server-side compiled).

It would be great to have the same thing with Twig.js. That way, the lib would weigh only a few kilobytes (instead of 66kB), and we could make the client download a "package" of all the templates altogether.

It would: save bandwidth, generate far fewer HTTP requests, and more importantly greatly reduce download time (important for me because I'm creating an app designed mostly for mobiles).

If it's already there, please forgive me for my question.

Best regards,

@justjohn

This comment has been minimized.

Show comment
Hide comment
@justjohn

justjohn Apr 29, 2013

Collaborator

This is something I've been poking at for a while. I started work on a tool for generating compiled templates a while back (bin/twigjs) but haven't had time to complete it. The goal of that tool will be to write out JS files for each template that rely on, as you suggest, a small core twig.js file.

Collaborator

justjohn commented Apr 29, 2013

This is something I've been poking at for a while. I started work on a tool for generating compiled templates a while back (bin/twigjs) but haven't had time to complete it. The goal of that tool will be to write out JS files for each template that rely on, as you suggest, a small core twig.js file.

@rkyoku

This comment has been minimized.

Show comment
Hide comment
@rkyoku

rkyoku Apr 29, 2013

Don't you already have both features in the full lib? Please do forgive my naive question, but shouldn't you "just" (mind the quotes :) ) copy/paste the "compile()" function in the server-side lib that would allow to build a package of all the tpl, and the "render()" function in the client-side lib? I apologize if it is too naive of me.
Best regards,

rkyoku commented Apr 29, 2013

Don't you already have both features in the full lib? Please do forgive my naive question, but shouldn't you "just" (mind the quotes :) ) copy/paste the "compile()" function in the server-side lib that would allow to build a package of all the tpl, and the "render()" function in the client-side lib? I apologize if it is too naive of me.
Best regards,

@dcorb

This comment has been minimized.

Show comment
Hide comment

dcorb commented May 11, 2016

+1

@vergilius

This comment has been minimized.

Show comment
Hide comment

+1

@dave-irvine

This comment has been minimized.

Show comment
Hide comment
@dave-irvine

dave-irvine Jun 1, 2016

Member

I've taken a look at this as it would be quite helpful for me, but I definitely don't think it is as easy as it might first appear.

Member

dave-irvine commented Jun 1, 2016

I've taken a look at this as it would be quite helpful for me, but I definitely don't think it is as easy as it might first appear.

@mishoo

This comment has been minimized.

Show comment
Hide comment
@mishoo

mishoo Mar 5, 2017

If anyone's still interested, I wrote a Twig->JS compiler. Whole new project though, I learned about this one half-through.

mishoo commented Mar 5, 2017

If anyone's still interested, I wrote a Twig->JS compiler. Whole new project though, I learned about this one half-through.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment