summaryrefslogtreecommitdiff
path: root/django/template/base.py
AgeCommit message (Collapse)Author
2015-04-01Fixed #23441, #24555 -- Improved the behavior of InclusionNode.Preston Timmons
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.
2015-03-27Fixed #18773 -- Added logging for template variable resolvingCaroline Simpson
Added a django.template logger without a default handler. Added logging if there is an exception while resolving variables in a template.
2015-03-20Cleaned up the template debug implementation.Preston Timmons
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.
2015-03-13Fed tuples to startswith when appropriateClaude Paroz
2015-03-02Fixed #24372 - Replaced TokenParser usage with traditional parsing.Preston Timmons
2015-02-20Removed a non-obvious side-effect of assigning Context.template.Aymeric Augustin
Explicit is better than implicit.
2015-02-19Set context.template instead of context.engine while rendering.Aymeric Augustin
This opens more possibilities, like accessing context.template.origin. It also follows the chain of objects instead of following a shortcut.
2015-02-06Sorted imports with isort; refs #23860.Tim Graham
2015-02-03Fixed #18651 -- Enabled optional assignments for simple_tag().Preston Timmons
2014-12-28Preserved context class in inclusion_tag.Aymeric Augustin
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.
2014-12-28Added a comment about the last use of Engine.get_default().Aymeric Augustin
2014-12-28Supported multiple template engines in get_template and select_template.Aymeric Augustin
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).
2014-12-28Removed some uses of global APIs from django.template.loader.Aymeric Augustin
2014-12-28Cleaned up the django.template namespace.Aymeric Augustin
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.
2014-12-27Fixed #23831 -- Supported strings escaped by third-party libs in Django.Aymeric Augustin
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.
2014-12-08Fixed #23968 -- Replaced list comprehension with generators and dict ↵Jon Dufresne
comprehension
2014-11-23Encapsulated TEMPLATE_DEBUG in Engine.Aymeric Augustin
2014-11-23Encapsulated TEMPLATE_STRING_IF_INVALID in Engine.Aymeric Augustin
2014-11-23Move compile_string into the Engine class.Aymeric Augustin
2014-11-23Added to each Context a reference to the Engine.Aymeric Augustin
It's only available during the rendering.
2014-11-23Introduced a template engine class.Aymeric Augustin
Moved Django templates loading infrastructure there.
2014-11-19Simplified caching of templatetags modules.Aymeric Augustin
2014-09-29Fixed #23489 -- Added numpy 1.9+ support in template lookupsTim Graham
2014-09-05Limited lines to 119 characters in django/Tim Graham
refs #23395.
2014-07-31Fixed #16383 -- Raised the AttributeError raised in property of an object ↵Anubhav Joshi
when used in a template. Thanks maraujop for the report and Hiroki and Tim Graham for review.
2014-07-01Fixed #22933 -- Deprecated django.template.resolve_variable().Tim Graham
2014-03-03Fixed many typos in comments and docstrings.Rodolfo Carvalho
Thanks Piotr Kasprzyk for help with the patch.
2014-02-23Removed incorrect statement from docstringPatrick Robertson
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.
2014-01-19Moved the loader tags registration with the other builtins.Baptiste Mispelon
2013-12-24Renamed AppCache to Apps.Aymeric Augustin
Also renamed app_cache to apps and "app cache" to "app registry". Deprecated AppCache.app_cache_ready() in favor of Apps.ready().
2013-12-22Moved apps back in the toplevel django namespace.Aymeric Augustin
Reverted 4a56a93cc458e9ab4dcab95d9f5067d4975dd1a2.
2013-12-22Stopped iterating on INSTALLED_APPS.Aymeric Augustin
Used the app cache's get_app_configs() method instead.
2013-12-14Fixed E127 pep8 warnings.Loic Bistuer
2013-11-09Fixed spelling of compatibility.Tim Graham
2013-11-08Fixed #17529 -- get_template_from_string default arguments breakUnai Zalakain
``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>'``.
2013-11-02Fixed the remaining E302 violations int eh django packageAlex Gaynor
2013-11-02More attacking E302 violatorsAlex Gaynor
2013-11-02Merge pull request #1848 from rayashmanjr/masterAlex Gaynor
Correct flake8 violation E261
2013-11-02Correct flake8 violation E261Ray Ashman Jr
2013-11-02Fixed #21302 -- Fixed unused imports and import *.Tim Graham
2013-10-18Fixed #21287 -- Fixed E123 pep8 warningsAlasdair Nicol
2013-10-17Fixed #21285 -- Fixed E121,E122 pep8 warningsAlasdair Nicol
2013-09-19Fixed #7557 -- Added type checking to Variable initialization.Tim Graham
Thanks tobias for the suggestion and boblefrag and saz for work on the patch.
2013-09-10Fixed #20841 -- Added messages to NotImplementedErrorsGregor MacGregor
Thanks joseph at vertstudios.com for the suggestion.
2013-09-09Simplify FilterExpression.args_checkCurtis Maloney
2013-09-08Fix #20745: Don't silence TypeError raised inside templates.Baptiste Mispelon
Thanks to robin for the report and claudep for the review.
2013-09-06Fixed #16096 -- Added origin attribute to template instances.Preston Timmons
Thanks jdunck for the suggestion.
2013-08-30Fixed #20989 -- Removed useless explicit list comprehensions.Simon Charette
2013-08-12Fixed #17778 -- Prevented class attributes on context from resolving as ↵Tim Graham
template variables. Thanks KyleMac for the report, regebro for the patch, and Aymeric for the test.
2013-07-29Removed most of absolute_import importsClaude Paroz
Should be unneeded with Python 2.7 and up. Added some unicode_literals along the way.