Skip to content

Commit

Permalink
Shows tried paths when template does not exists
Browse files Browse the repository at this point in the history
  • Loading branch information
alanjds committed Dec 19, 2013
1 parent 4551d44 commit d0a163e
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions django_mobile/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,24 @@ def __init__(self, *args, **kwargs):
self.template_source_loaders = tuple(loaders)
super(BaseLoader, self).__init__(*args, **kwargs)

def get_template_sources(self, template_name, template_dirs=None):
template_name = self.prepare_template_name(template_name)
for loader in self.template_source_loaders:
if hasattr(loader, 'get_template_sources'):
try:
for result in loader.get_template_sources(
template_name,
template_dirs):
yield result
except UnicodeDecodeError:
# The template dir name was a bytestring that wasn't valid UTF-8.
raise
except ValueError:
# The joined path was located outside of this particular
# template_dir (it might be inside another one, so this isn't
# fatal).
pass

def prepare_template_name(self, template_name):
template_name = u'%s/%s' % (get_flavour(), template_name)
if settings.FLAVOURS_TEMPLATE_PREFIX:
Expand Down

0 comments on commit d0a163e

Please sign in to comment.