schmittjoh/twig.js — Issue #21: Requesting adding "extensions" behaviour to twig.environment
Author: jonathaningram
Created: 2012-03-06 15:07:15+00:00
State: open

As part of my FormExtension.js work, it seems to me that is makes sense for my extension to be registered In the twig environment via twig.environment.addExtension (I.e. verbatim to \Twig_Environment).

Two queries:

1. Does it seem reasonable to do this? In which case the extension can also provide additional globals, filters, functions as per Twig
2. This means that the current implementation won't work until it is updated to use extensions too (I think). E.g. instead of having a call to my method FormExtension.render_errors, as per Twig, I'd like the compiler to generate "this.env_.getExtension('form').renderErrors(...)" (I can't remember the exact syntax right now).

What do you think? Sound like this is the way to go ahead?