| Age | Commit message (Collapse) | Author |
|
This change:
* Makes the InclusionNode cache-safe by removing render-time side effects
to its nodelist.
* Ensures the render_context stack is properly scoped and reset by updating
the render call to use Template.render rather than Nodelist.render.
|
|
Added a django.template logger without a default handler. Added
logging if there is an exception while resolving variables in a
template.
|
|
This patch does three major things:
* Merges the django.template.debug implementation into django.template.base.
* Simplifies the debug implementation.
The old implementation copied debug information to every token and node.
The django_template_source attribute was set in multiple places, some
quite hacky, like django.template.defaulttags.ForNode.
Debug information is now annotated in two high-level places:
* Template.compile_nodelist for errors during parsing
* Node.render_annotated for errors during rendering
These were chosen because they have access to the template and context
as well as to all exceptions that happen during either the parse or
render phase.
* Moves the contextual line traceback information creation from
django.views.debug into django.template.base.Template. The debug views now
only deal with the presentation of the debug information.
|
|
|
|
|
|
Explicit is better than implicit.
|
|
This opens more possibilities, like accessing context.template.origin.
It also follows the chain of objects instead of following a shortcut.
|
|
|
|
|
|
Previously, when a template was rendered with RequestContext, inclusion
tags were rendered with a plain context, losing additional information
available in the RequestContext.
The (admittedly bizarre) implementation of RequestContext.new() has the
side-effect of not running template context processors, making this
change backwards-compatible.
|
|
|
|
This commit changes the return type of these two functions. Instead of
returning a django.template.Template they return a backend-specific
Template class that must implement render(self, context).
|
|
|
|
Since this package is going to hold both the implementation of the Django
Template Language and the infrastructure for Multiple Template Engines,
it should be untied from the DTL as much as possible within our
backwards-compatibility policy.
Only public APIs (i.e. APIs mentioned in the documentation) were left.
|
|
Refs #7261 -- Made strings escaped by Django usable in third-party libs.
The changes in mark_safe and mark_for_escaping are straightforward. The
more tricky part is to handle correctly objects that implement __html__.
Historically escape() has escaped SafeData. Even if that doesn't seem a
good behavior, changing it would create security concerns. Therefore
support for __html__() was only added to conditional_escape() where this
concern doesn't exist.
Then using conditional_escape() instead of escape() in the Django
template engine makes it understand data escaped by other libraries.
Template filter |escape accounts for __html__() when it's available.
|force_escape forces the use of Django's HTML escaping implementation.
Here's why the change in render_value_in_context() is safe. Before Django
1.7 conditional_escape() was implemented as follows:
if isinstance(text, SafeData):
return text
else:
return escape(text)
render_value_in_context() never called escape() on SafeData. Therefore
replacing escape() with conditional_escape() doesn't change the
autoescaping logic as it was originally intended.
This change should be backported to Django 1.7 because it corrects a
feature added in Django 1.7.
Thanks mitsuhiko for the report.
|
|
comprehension
|
|
|
|
|
|
|
|
It's only available during the rendering.
|
|
Moved Django templates loading infrastructure there.
|
|
|
|
|
|
refs #23395.
|
|
when used in a template.
Thanks maraujop for the report and Hiroki and Tim Graham for review.
|
|
|
|
Thanks Piotr Kasprzyk for help with the patch.
|
|
The docstring of FilterExpression said that it shouldn't be
instantiated from anywhere but the get_filters_from_token
helper function.
However, that helper function was deleted in commit
3ede006fc98f7e96ae9fb997872f78635576d5f8 and FilterExpression
is instantiated from inside the compile_filter help function.
|
|
|
|
Also renamed app_cache to apps and "app cache" to "app registry".
Deprecated AppCache.app_cache_ready() in favor of Apps.ready().
|
|
Reverted 4a56a93cc458e9ab4dcab95d9f5067d4975dd1a2.
|
|
Used the app cache's get_app_configs() method instead.
|
|
|
|
|
|
``get_template_from_string`` default arguments were breaking
``assertTemplateUsed``. The solution has been to return only the names of the
templates with a ``name`` attribute distinct of ``None``. The default ``name``
kwarg of ``Template`` has been changed to ``None``, more pythonic than ``'<Unknown
Template>'``.
|
|
|
|
|
|
Correct flake8 violation E261
|
|
|
|
|
|
|
|
|
|
Thanks tobias for the suggestion and boblefrag and saz for work on the
patch.
|
|
Thanks joseph at vertstudios.com for the suggestion.
|
|
|
|
Thanks to robin for the report and claudep for the review.
|
|
Thanks jdunck for the suggestion.
|
|
|
|
template variables.
Thanks KyleMac for the report, regebro for the patch, and Aymeric for the test.
|
|
Should be unneeded with Python 2.7 and up.
Added some unicode_literals along the way.
|