Closed bblanchon closed 4 years ago
Seems pretty reasonable. Thanks for including tests!
Any idea if there are changes that should be made to the Jinja code in this situation?
No, I don't know if there is something similar for Jinja, but since Context
is in the django.template
namespace, the user knows it's a feature limited to Django templates.
BTW, django-templated-email expects this behavior; they've been waiting for a fix since 2017 😮.
No, I don't know if there is something similar for Jinja, but since
Context
is in thedjango.template
namespace, the user knows it's a feature limited to Django templates.
Right so theoretically you could create a django.template.Context
instance and pass it into render_block_to_string
which could call into the Jinja2 code. That's just silly (although I actually think Jinja2 would convert it to a dict, which probably works). Anyway, I don't think we need to do anything about it.
FYI I released 0.8 with this change in it. Thanks!
This pull request makes
render_block_to_string()
forwards theContext
instance provided by the user.For example, this allows the user to disable autoescape, like so:
Such a feature is handy when rendering a text-only template, like an email or a notification message.