Clarify docs and add EXCLUDE_APPS default. Fix #22.

This commit is contained in:
James Socol
2012-11-09 12:32:36 -05:00
parent f705931711
commit 6736d3b0fd
3 changed files with 39 additions and 9 deletions

View File

@@ -65,12 +65,24 @@ from the loader::
JINGO_EXCLUDE_APPS = ('debug_toolbar',)
If a template is in the *app folder*, ``debug_toolbar``, the Jinja loader will
raise a ``TemplateDoesNotExist`` exception.
This causes Django to move onto the next loader in ``TEMPLATE_LOADERS``
to find a template - in this case,
If a template path begins with ``debug_toolbar``, the Jinja loader will raise a
``TemplateDoesNotExist`` exception. This causes Django to move onto the next
loader in ``TEMPLATE_LOADERS`` to find a template - in this case,
``django.template.loaders.filesystem.Loader``.
.. note::
Technically, we're looking at the template path, not the app. Often these are
the same, but in some cases, like 'registration' in the default setting--which
is an admin template--they are not.
The default is in ``jingo.EXCLUDE_APPS``::
EXCLUDE_APPS = (
'admin',
'admindocs',
'registration'
)
If you want to configure the Jinja environment, use ``JINJA_CONFIG`` in
``settings.py``. It can be a dict or a function that returns a dict. ::

View File

@@ -65,12 +65,24 @@ from the loader::
JINGO_EXCLUDE_APPS = ('debug_toolbar',)
If a template is in the *app folder*, ``debug_toolbar``, the Jinja loader will
raise a ``TemplateDoesNotExist`` exception.
This causes Django to move onto the next loader in ``TEMPLATE_LOADERS``
to find a template - in this case,
If a template path begins with ``debug_toolbar``, the Jinja loader will raise a
``TemplateDoesNotExist`` exception. This causes Django to move onto the next
loader in ``TEMPLATE_LOADERS`` to find a template - in this case,
``django.template.loaders.filesystem.Loader``.
.. note::
Technically, we're looking at the template path, not the app. Often these are
the same, but in some cases, like 'registration' in the default setting--which
is an admin template--they are not.
The default is in ``jingo.EXCLUDE_APPS``::
EXCLUDE_APPS = (
'admin',
'admindocs',
'registration'
)
If you want to configure the Jinja environment, use ``JINJA_CONFIG`` in
``settings.py``. It can be a dict or a function that returns a dict. ::

View File

@@ -16,6 +16,12 @@ import jinja2
VERSION = (0, 4)
__version__ = '.'.join(map(str, VERSION))
EXCLUDE_APPS = (
'admin',
'admindocs',
'registration',
)
log = logging.getLogger('jingo')
_helpers_loaded = False
@@ -204,7 +210,7 @@ class Loader(BaseLoader):
def load_template(self, template_name, template_dirs=None):
if hasattr(template_name, 'rsplit'):
app = template_name.rsplit('/')[0]
if app in getattr(settings, 'JINGO_EXCLUDE_APPS', []):
if app in getattr(settings, 'JINGO_EXCLUDE_APPS', EXCLUDE_APPS):
raise TemplateDoesNotExist(template_name)
try:
template = env.get_template(template_name)