From 536795f79a956febc06a7fa5c86e3a395f2c94eb Mon Sep 17 00:00:00 2001 From: Preston Timmons Date: Sun, 16 Nov 2014 17:13:40 -0600 Subject: [PATCH] Fixed #23849 -- Documented the locmem.Loader class. --- docs/ref/templates/api.txt | 22 ++++++++++++++++++++-- docs/releases/1.8.txt | 3 +++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/docs/ref/templates/api.txt b/docs/ref/templates/api.txt index 6a3f160af3..834e57e006 100644 --- a/docs/ref/templates/api.txt +++ b/docs/ref/templates/api.txt @@ -735,7 +735,7 @@ sources. Some of these other loaders are disabled by default, but you can activate them by editing your :setting:`TEMPLATE_LOADERS` setting. :setting:`TEMPLATE_LOADERS` -should be a tuple of strings, where each string represents a template loader +should be a tuple of strings or tuples, where each represents a template loader class. Here are the template loaders that come with Django: .. currentmodule:: django.template.loaders @@ -778,7 +778,7 @@ class. Here are the template loaders that come with Django: ``django.contrib.admin`` in :setting:`INSTALLED_APPS`, otherwise ``django.contrib.admin``’s will be loaded first and yours will be ignored. - Note that the loader performs an optimization when it is first imported: + Note that the loader performs an optimization when it first runs: it caches a list of which :setting:`INSTALLED_APPS` packages have a ``templates`` subdirectory. @@ -828,6 +828,24 @@ class. Here are the template loaders that come with Django: This loader is disabled by default. +``django.template.loaders.locmem.Loader`` + +.. versionadded:: 1.8 + +.. class:: locmem.Loader + + Loads templates from a Python dictionary. This is useful for testing. + + This loader takes a dictionary of templates as its first argument:: + + TEMPLATE_LOADERS = ( + ('django.template.loaders.locmem.Loader', { + 'index.html': 'content here', + }), + ) + + This loader is disabled by default. + Django uses the template loaders in order according to the :setting:`TEMPLATE_LOADERS` setting. It uses each loader until a loader finds a match. diff --git a/docs/releases/1.8.txt b/docs/releases/1.8.txt index 9520f84686..77ab5eec80 100644 --- a/docs/releases/1.8.txt +++ b/docs/releases/1.8.txt @@ -414,6 +414,9 @@ Templates its query string as part of the URL (the URL in e.g. ``'djangoproject.com!`` is ``djangoproject.com``) +* Added a :class:`locmem.Loader ` + class that loads Django templates from a Python dictionary. + Requests and Responses ^^^^^^^^^^^^^^^^^^^^^^