-
-
Notifications
You must be signed in to change notification settings - Fork 268
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
Access context from filter #267
Labels
Comments
Support this. Without context the filter misses lots of state/context. In my case I had to switch to function to use context but filter is semantically correct because it's about output. My case: #200 (comment) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It would be a good feature if we could access the context from a filter and use some global variables here, like the selected language, using of preview mode, etc.
For example, consider the following email template:
Here we have a custom filter, which can translate the corresponding strings. But we have to pass the
ln
param to every filter, because the filter itself doesn't know the actual language, however it has been set in the context (context["ln"] = "en"
).Another example is an embedded image:
<img src="{{'spacer.gif'|images:preview}}"/>
Here the filter replaces the src to a full URL (in preview mode) or to a
cid:xxxx
embed mark. Another issue here is that we need to store somehow which images we should include later, when sending the actual mail, so we can embed them. Now we have to rescan the template file, looking for src attribs and css backgrounds, and get the images from here, however theimages
filter could do that for us and store the image list on the context itself. Later we can easily grab the info from here.Thanks for your great work!
The text was updated successfully, but these errors were encountered: