summaryrefslogtreecommitdiff
path: root/django/template/engine.py
AgeCommit message (Collapse)Author
2025-08-14Fixed #36410 -- Added support for Template Partials to the Django Template ↵farhan
Language. Introduced `{% partialdef %}` and `{% partial %}` template tags to define and render reusable named fragments within a template file. Partials can also be accessed using the `template_name#partial_name` syntax via `get_template()`, `render()`, `{% include %}`, and other template-loading tools. Adjusted `get_template()` behavior to support partial resolution, with appropriate error handling for invalid names and edge cases. Introduced `PartialTemplate` to encapsulate partial rendering behavior. Includes tests and internal refactors to support partial context binding, exception reporting, and tag validation. Co-authored-by: Carlton Gibson <carlton@noumenal.es> Co-authored-by: Natalia <124304+nessita@users.noreply.github.com> Co-authored-by: Nick Pope <nick@nickpope.me.uk>
2024-01-26Applied Black's 2024 stable style.Mariusz Felisiak
https://github.com/psf/black/releases/tag/24.1.0
2022-04-19Fixed #33639 -- Enabled cached template loader in development.Carlton Gibson
2022-02-07Refs #33476 -- Reformatted code with Black.django-bot
2021-09-27Refs #32355 -- Used @functools.lru_cache as a straight decorator.Mariusz Felisiak
2021-06-01Refs #24121 -- Added __repr__() to Engineabhiabhi94
2019-09-24Removed some outdated backwards compatibility imports and misleading comments.Mads Jensen
EmptyResultSet moved in 46509cf13dbf049f75077981c29ef2c60b5a96ab. FieldDoesNotExist moved in 8958170755b37ce346ae5257c1000bd936faa3b0. BoundField and pretty_name moved in 8550161e531a603d57723850fb09c4c9b7ca60b9. EMPTY_VALUES moved in 471596fc1afcb9c6258d317c619eaf5fd394e797. BaseRunserverCommand moved in 5c53e30607014163872e89c221b206992a9acfef.
2019-03-25Fixed #29791 -- Made Engine.render_to_string() honor autoescape.Nathan Gaberel
2018-09-28Refs #28909 -- Simplifed code using unpacking generalizations.Sergey Fedoseev
2017-03-31Fixed #27359 -- Made Engine.get_default() return the first DjangoTemplates ↵Carlton Gibson
engine if multiple are defined.
2017-02-17Refs #27656 -- Updated django.template/tag docstring verbs according to PEP 257.Anton Samarchyan
2017-01-19Refs #23919 -- Stopped inheriting from object to define new style classes.Simon Charette
2017-01-18Refs #23919 -- Stopped using django.utils.lru_cache().Aymeric Augustin
2017-01-18Refs #23919 -- Removed six.<various>_types usageClaude Paroz
Thanks Tim Graham and Simon Charette for the reviews.
2017-01-17Refs #15053 -- Removed support for non-recursive template loading.Tim Graham
Per deprecation timeline.
2016-09-03Fixed #25788 -- Enabled the cached template loader if debug is False.Tim Graham
2015-11-12Fixed #25469 -- Added autoescape option to DjangoTemplates backend.Aaron Elliot Ross
Thanks Aymeric for the initial patch and Carl for review.
2015-09-24Added django.template.engine.Engine.render_to_string() docstring.Tim Graham
2015-09-23Removed template.loader.BaseLoader per deprecation timeline.Tim Graham
2015-09-23Removed dictionary and context_instance parameters for render functions.Tim Graham
Per deprecation timeline.
2015-09-23Removed dirs parameter in template engine methods and related funtions.Tim Graham
Per deprecation timeline.
2015-09-23Refs #24022 -- Removed the ssi tag per deprecation timeline.Tim Graham
2015-06-24Renamed RemovedInDjangoXYWarnings for new roadmap.Tim Graham
Forwardport of ae1d663b7913f6da233c55409c4973248372d302 from stable/1.8.x plus more.
2015-05-21Fixed #17085, #24783 -- Refactored template library registration.Preston Timmons
* Converted the ``libraries`` and ``builtins`` globals of ``django.template.base`` into properties of the Engine class. * Added a public API for explicit registration of libraries and builtins.
2015-05-06Moved engine-related exceptions to django.template.exceptions.Preston Timmons
With the introduction of multiple template engines these exceptions are no longer DTL-specific. It makes more sense for them to be moved out of DTL-related modules.
2015-04-22Fixed #15053 -- Enabled recursive template loading.Preston Timmons
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-02-06Sorted imports with isort; refs #23860.Tim Graham
2015-02-04Fixed #24235 -- Removed is_usable attribute from template loaders.Preston Timmons
2015-01-07Exposed Engine in the django.template namespace.Aymeric Augustin
It's the main entrypoint to the refactored template system.
2015-01-06Added comments to remove Engine.render_to_string in Django 2.0.Aymeric Augustin
Since this is a private API introduced in Django 1.8, no documentation is required.
2014-12-28Raised an error when allowed_include_roots is a string.Aymeric Augustin
This avoids leaving projects silently vulnerable when this option is set to a string instead of a one-item tuple containing that string, a very common misconfiguration.
2014-12-28Supported multiple template engines in render_to_string.Aymeric Augustin
Adjusted its API through a deprecation path according to the DEP.
2014-12-28Removed extraneous arguments in Engine.from_string.Aymeric Augustin
This aligns the Django Template Engine API with the common template backend API.
2014-12-28Looked up the default template engine in the list of all engines.Aymeric Augustin
2014-12-28Passed a reference to the current engine when instantiating Template.Aymeric Augustin
2014-12-28Renamed get_template_from_string to from_string.Aymeric Augustin
The shorter name is just as explicit and, well, shorter.
2014-12-28Simplified handling of a default value.Aymeric Augustin
2014-11-23Encapsulated TEMPLATE_DEBUG in Engine.Aymeric Augustin
2014-11-23Encapsulated TEMPLATE_CONTEXT_PROCESSORS in Engine.Aymeric Augustin
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.
2014-11-23Moved make_origin into the Engine class.Aymeric Augustin
2014-11-23Move compile_string into the Engine class.Aymeric Augustin
2014-11-23Removed dependency of template loaders on Django settings.Aymeric Augustin
2014-11-23Moved template loaders management in Engine.Aymeric Augustin
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.
2014-11-23Removed unused API get_template_loaders.Aymeric Augustin
It was introduced in a recent refactoring so this isn't an issue. Then renamed _get_template_loaders to get_template_loaders.
2014-11-23Introduced a template engine class.Aymeric Augustin
Moved Django templates loading infrastructure there.