Arthur de Jong

Open Source / Free Software developer

summaryrefslogtreecommitdiffstats
path: root/django/template
Commit message (Collapse)AuthorAgeFilesLines
...
* Moved context_processors from django.core to ↵Aymeric Augustin2014-12-282-1/+86
| | | | django.template.
* Added a comment about the last use of Engine.get_default().Aymeric Augustin2014-12-281-0/+4
|
* Supported multiple template engines in render_to_string.Aymeric Augustin2014-12-282-13/+84
| | | | Adjusted its API through a deprecation path according to the DEP.
* Removed extraneous arguments in Engine.from_string.Aymeric Augustin2014-12-283-7/+7
| | | | | This aligns the Django Template Engine API with the common template backend API.
* Removed private API get_template_from_string.Aymeric Augustin2014-12-281-4/+0
| | | | It wasn't documented and it wasn't used anywhere.
* Removed private API find_template.Aymeric Augustin2014-12-281-4/+0
| | | | | It wasn't documented and it wasn't used anywhere, except in a few tests that don't test it specifically and can be rewritten with get_template.
* Supported multiple template engines in get_template and ↵Aymeric Augustin2014-12-283-13/+79
| | | | | | | | select_template. 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).
* Looked up the default template engine in the list of all ↵Aymeric Augustin2014-12-282-19/+40
| | | | engines.
* Passed a reference to the current engine when ↵Aymeric Augustin2014-12-282-2/+2
| | | | instantiating Template.
* Removed some uses of global APIs from ↵Aymeric Augustin2014-12-284-10/+6
| | | | django.template.loader.
* Added Django template backend.Aymeric Augustin2014-12-285-0/+53
|
* Added jinja2 template backend.Aymeric Augustin2014-12-281-0/+58
|
* Added dummy template backend.Aymeric Augustin2014-12-282-0/+66
|
* Added initial support for loading template engines.Aymeric Augustin2014-12-282-1/+111
|
* Imported BaseEngine from the DEP.Aymeric Augustin2014-12-282-0/+80
| | | | i18n is left aside for now.
* Cleaned up the django.template namespace.Aymeric Augustin2014-12-282-73/+61
| | | | | | | | | 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.
* Renamed get_template_from_string to from_string.Aymeric Augustin2014-12-282-9/+9
| | | | The shorter name is just as explicit and, well, shorter.
* Simplified handling of a default value.Aymeric Augustin2014-12-281-3/+1
|
* Fixed #23831 -- Supported strings escaped by third-party ↵Aymeric Augustin2014-12-272-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | libs in Django. 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.
* Fixed #23968 -- Replaced list comprehension with ↵Jon Dufresne2014-12-083-8/+8
| | | | generators and dict comprehension
* Removed redundant numbered parameters from str.format().Berker Peksag2014-12-031-2/+2
| | | | Since Python 2.7 and 3.1, "{0} {1}" is equivalent to "{} {}".
* Fixed #23914 -- Improved {% now %} to allow storing its ↵Baptiste Mispelon2014-11-251-3/+14
| | | | | | result in the context. Thanks to Tim for the review.
* Encapsulated TEMPLATE_DEBUG in Engine.Aymeric Augustin2014-11-234-9/+9
|
* Encapsulated TEMPLATE_STRING_IF_INVALID in Engine.Aymeric Augustin2014-11-231-15/+10
|
* Encapsulated TEMPLATE_CONTEXT_PROCESSORS in Engine.Aymeric Augustin2014-11-232-18/+37
| | | | | | Since RequestContext doesn't know its Engine until it's passed to Template.render() -- and cannot without breaking a widely used public API -- an elaborate hack is required to apply context processors.
* Encapsulated ALLOWED_INCLUDE_ROOTS in Engine.Aymeric Augustin2014-11-231-3/+3
|
* Moved make_origin into the Engine class.Aymeric Augustin2014-11-234-15/+15
|
* Move compile_string into the Engine class.Aymeric Augustin2014-11-233-16/+18
|
* Added to each Context a reference to the Engine.Aymeric Augustin2014-11-232-3/+13
| | | | It's only available during the rendering.
* Removed dependency of template loaders on Django settings.Aymeric Augustin2014-11-234-9/+12
|
* Moved template loaders management in Engine.Aymeric Augustin2014-11-236-51/+57
| | | | | | | | | | | Passed the engine instance to loaders. This is a prerequisite for looking up configuration on the engine instance instead of global settings. This is backwards incompatible for custom template loaders that override __init__. However the documentation doesn't talk about __init__ and the way to pass arguments to custom template loaders isn't specified. I'm considering it a private API.
* Removed unused API get_template_loaders.Aymeric Augustin2014-11-233-14/+6
| | | | | | It was introduced in a recent refactoring so this isn't an issue. Then renamed _get_template_loaders to get_template_loaders.
* Introduced a template engine class.Aymeric Augustin2014-11-233-96/+174
| | | | Moved Django templates loading infrastructure there.
* Deprecated dirs argument to override TEMPLATE_DIRS.Aymeric Augustin2014-11-231-3/+31
| | | | Cancels 2f0566fa. Refs #4278.
* Avoided rewrapping Contexts in render_to_response.Aymeric Augustin2014-11-221-1/+6
| | | | | | | | | | | | | This change preserves backwards-compatibility for a very common misuse of render_to_response which even occurred in the official documentation. It fixes that misuse wherever it happened in the code base and docs. Context.__init__ is documented as accepting a dict and nothing else. Since Context is dict-like, Context(Context({})) could work to some extent. However, things get complicated with RequestContext and that gets in the way of refactoring the template engine. This is the real rationale for this change.
* Simplified caching of template context processors.Aymeric Augustin2014-11-191-16/+7
|
* Simplified caching of templatetags modules.Aymeric Augustin2014-11-191-19/+15
|
* Removed support for function-based template loaders.Aymeric Augustin2014-11-161-21/+6
| | | | | | | | They were deprecated in Django 1.2 but not all the supporting code was removed in Django 1.4. Since the remaining code was unlikely to be functional (pun intended) e.g. it would crash unless the loader function had an is_usable attribute, this commit completes the removal immediately instead of starting another deprecation path.
* Used get_template_loaders in the cached loader.Aymeric Augustin2014-11-162-17/+10
| | | | | | This ensures that enabling the cached loader doesn't change behavior. (Before this commit, it did when the list contained unusable loaders.)
* Refactored getting the list of template loaders.Aymeric Augustin2014-11-163-58/+62
| | | | | This provides the opportunity to move utility functions specific to the Django Template Language outside of django.template.loader.
* Deprecated function-based loaders.Aymeric Augustin2014-11-161-0/+6
|
* Removed obsolete comment.Aymeric Augustin2014-11-161-27/+0
| | | | It didn't account for class-based template loaders.
* Refactored listing template subdirectories in apps.Aymeric Augustin2014-11-162-24/+31
| | | | | | This change has the nice side effect of removing code that ran at import time and depended on the app registry at module level -- a notorious cause of AppRegistryNotReady exceptions.
* Removed skip_template argument of ↵Aymeric Augustin2014-11-161-2/+1
| | | | | | locmem.Loader.load_template_source. It didn't do anything, wasn't documented and wasn't used anywhere.
* Removed the "test:" prefix from locmem template identifiers.Aymeric Augustin2014-11-161-2/+1
| | | | | | | Since it isn't branded as a test utility any more and could be used for other purposes than test code, that prefix no longer makes sense. It wasn't used anywhere either.
* Moved all template loaders under django.template.loaders.Aymeric Augustin2014-11-167-43/+95
| | | | | | | | | | | | Reformatted the code of base.Loader according to modern standards. Turned the test template loader into a regular locmem.Loader -- but didn't document it. Added a normal deprecation path for BaseLoader which is a public API. Added an accelerated deprecation path for TestTemplateLoader which is a private API.
* Fixed #23585 - Corrected internal comment.Grzegorz Slusarek2014-11-151-3/+1
| | | | | Removed misleading comment and provide correct one, explaining idea behind hardcoded CSRF template context processor.
* Fixed #23730 -- Moved support for SimpleCookie ↵Tim Graham2014-11-121-1/+1
| | | | | | | | HIGHEST_PROTOCOL pickling to http.cookie. This fix is necessary for Python 3.5 compatibility (refs #23763). Thanks Berker Peksag for review.
* Normalized opening a file and decoding its content.Aymeric Augustin2014-11-112-4/+7
| | | | `io.open` is required on Python 2.7. Just `open` would work on Python 3.
* Raised SuspiciousFileOperation in safe_join.Aymeric Augustin2014-11-112-12/+8
| | | | | | | | | | | | | | | Added a test for the condition safe_join is designed to prevent. Previously, a generic ValueError was raised. It was impossible to tell an intentional exception raised to implement safe_join's contract from an unintentional exception caused by incorrect inputs or unexpected conditions. That resulted in bizarre exception catching patterns, which this patch removes. Since safe_join is a private API and since the change is unlikely to create security issues for users who use it anyway -- at worst, an uncaught SuspiciousFileOperation exception will bubble up -- it isn't documented.