forked from GaretJax/coffin
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of git://github.com/coffin/coffin
Conflicts: coffin/common.py coffin/template/loaders.py
- Loading branch information
Showing
16 changed files
with
397 additions
and
110 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,11 @@ | ||
0.3.7 (2012-09-29) | ||
- Support for Django 1.3 class-based views (Kirill Zaitsev, | ||
Dmitry Panteleev) | ||
- Loader for *.jinja files (Aarni Koskela) | ||
- makemessages command now supports whitespace stripping tags | ||
(Dmitry Panteleev) | ||
- Now supports Django's CachedLoader. | ||
|
||
0.3.6 (2011-09-09) | ||
- Re-release of 0.3.5, containing the correct repository | ||
- Re-release of 0.3.5, containing the correct repository | ||
state this time. |
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
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,47 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
A Django template loader wrapper for Coffin that intercepts | ||
requests for "*.jinja" templates, rendering them with Coffin | ||
instead of Django templates. | ||
Usage: | ||
TEMPLATE_LOADERS = ( | ||
'coffin.contrib.loader.AppLoader', | ||
'coffin.contrib.loader.FileSystemLoader', | ||
) | ||
""" | ||
|
||
from os.path import splitext | ||
from coffin.common import env | ||
from django.conf import settings | ||
from django.template.loaders import app_directories, filesystem | ||
|
||
|
||
JINJA2_DEFAULT_TEMPLATE_EXTENSION = getattr(settings, | ||
'JINJA2_DEFAULT_TEMPLATE_EXTENSION', ('.jinja',)) | ||
|
||
if isinstance(JINJA2_DEFAULT_TEMPLATE_EXTENSION, basestring): | ||
JINJA2_DEFAULT_TEMPLATE_EXTENSION = (JINJA2_DEFAULT_TEMPLATE_EXTENSION,) | ||
|
||
|
||
class LoaderMixin(object): | ||
is_usable = True | ||
|
||
def load_template(self, template_name, template_dirs=None): | ||
extension = splitext(template_name)[1] | ||
|
||
if not extension in JINJA2_DEFAULT_TEMPLATE_EXTENSION: | ||
return super(LoaderMixin, self).load_template(template_name, | ||
template_dirs) | ||
template = env.get_template(template_name) | ||
return template, template.filename | ||
|
||
|
||
class FileSystemLoader(LoaderMixin, filesystem.Loader): | ||
pass | ||
|
||
|
||
class AppLoader(LoaderMixin, app_directories.Loader): | ||
pass |
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
Oops, something went wrong.