Hi Armin,

thanks for the background information and the tip to use monkey patch,
it works now.

My implementation maps Jinja macros to JavaScript functions so all
variables are local to the function so hopefully simplifying things.
When I get time I will try and document what is supported by my JS
code generator and try to write compile time checks that complain
about what I don't support.

I am not going to be writing any more translators so I wouldn't worry
about an API, it was surprisingly easy to get to where I am.

Michael

On 28 February 2011 09:47, Armin Ronacher <[email protected]> wrote:
> Hi,
>
> On 2/21/11 8:48 PM, Michael Kerrin wrote:
>>
>> Just letting you know I have recently started a project on github at
>> https://github.com/mkerrin/pwt.jscompiler that extends Jinja2 to
>> generate JavaScript instead of Python. The project also contains a
>> simple WSGI application to serve template files as JavaScript.
>
> I don't have the time currently to review this in detail, but generally
> Jinja2 and JavaScript compilation is something that we always had in mind
> originally and dropped step by step in later versions.
>
> Jinja1 had a pluggable translator interface and I had a prototype that
> generated JavaScript for a while.  The problem currently is that very few
> people are actually using that (for good reason) and that supporting it is a
> lot of work.  As you might have noticed the code generator also does a lot
> of magic in order to track local variable usage.  This is totally *not*
> designed to be pluggable or to be a public interface.  In fact there is
> currently a problematic bug where Jinja2's scoping rules cannot be mapped on
> top of Python's so that identifier tracking might change soonish.
>
> Great work though if it works, maybe we can find an API on top of the
> current code generator that might support external alternative translators.
>
> Regarding nodes: you can monkey patch the check away, but that check exists
> for good reasons: if you pass an unsupported node to the core translator it
> will barf and break.
>
>
> Regards,
> Armin
>
> --
> You received this message because you are subscribed to the Google Groups
> "pocoo-libs" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/pocoo-libs?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"pocoo-libs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/pocoo-libs?hl=en.

Reply via email to