justjohn/twig.js — Issue #2: Generating Javascript code
Author: soywiz
Created: 2012-01-11 23:45:38+00:00
State: open

It would be great if the Template.render were a plain Javascript function. At this moment if I'm not wrong it just interprets a set of nodes instead of creating a native javascript function with "eval".

Because of the overhead of that interpretation, it is a bit slow for me.

Here is a project that generates javascript code (thought it is generated by PHP):
https://github.com/schmittjoh/twig.js

But the idea is similar: the engine loads the template, compiles it into plain Javascript and then returns a javascript native function that can be executed directly.

I have done something similar for .NET: https://github.com/soywiz/csharputils/tree/master/CSharpUtils/CSharpUtils.Templates/Templates

If you want I can help you implementing the javascript dynarec for twig.js.