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
Adding Jinja2TemplateFilter #20
Conversation
This allows us to run static assets through Jinja2's templateing engine (using Flask's standard template contexts).
…ets`. This was, the temalte filter will be available to any flask-assets users.
from webassets.filter import Filter, register_filter | ||
|
||
|
||
class Jinja2TemplateFilter(Filter): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should keep the class names in line with webassets, i.e. without a suffix.
Does the packaging work with this separate file? It will be configured to install flask_assets.py as a root-level module, and probably skip filter.py completely. You will need to make Alternatively, while splitting the code across multiple files will likely have to happen sooner or later, it would be easiest for now to just define the filter class inside |
Also, and I am a bit on the fence on this, How do you feel about making it replace the base |
That's a great point, re: overriding the base Also: from my testing, the filter.py fille works fine separately. The way I tested it so far was just to run the entire thing via Why don't I just move the filter inside the So, for now I'll:
Is that acceptable? |
Sounds great. FWIW, what presumably happens is that it installs |
Hey, so I'm working on this right now, but I've actually got a question. In webassets, the So that I don't break any style conventions here, would you prefer that I:
|
I had assumed that register_filter() would allow overwriting; so that's what I would suggest to do. It makes sense that there would be an "official" way to accomplish this. |
And having it override the build-in ``jinja2`` template, so that we get the included Flask contexts by default.
So, just updated this pull request like we discussed. It works locally (when tested). Obviously, this will still not work unless |
Actually, installing the development version should automatically pull the dev version of webassets too :) |
Heya, this references issue #19. I thought I'd submit this pull request, which adds a
Jinja2TemplateFilter
to flask-assets (exposed under the namejinja2template
). It is automatically registered when flask_assets is imported, so it should be usable out of the box.This obviously requires the latest development release of
webassets
to run (since I just got my initialjinja2
filter accepted there), so I'm not sure if you'd like to merge this now, or wait tillwebassets
makes a new stable release.Either way, I thought I'd leave this here to see what you think.