Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improved kajiki loader to solve some issues with py:extends
- Loading branch information
Showing
2 changed files
with
28 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
"""Kajiki template loader that supports dotted names with relative paths.""" | ||
|
||
from kajiki.loader import FileLoader | ||
|
||
from tg import config | ||
|
||
|
||
class KajikiTemplateLoader(FileLoader): | ||
"""Kaijik template loader supporting dotted filenames. | ||
Solves also the issue of not supporting relative paths when using | ||
py:extends in Kaijiki | ||
""" | ||
|
||
template_extension = '.xml' | ||
|
||
def __init__(self, base, reload=True, force_mode=None): | ||
super(KajikiTemplateLoader, self).__init__(base, reload, force_mode) | ||
|
||
def _filename(self, filename): | ||
if not filename.endswith(self.template_extension): | ||
finder = config['pylons.app_globals'].dotted_filename_finder | ||
filename = finder.get_dotted_filename(template_name=filename, | ||
template_extension=self.template_extension) | ||
return super(KajikiTemplateLoader, self)._filename(filename) |