Closed aisbaa closed 10 years ago
I'm could be missing something very important, but this loader seems to work just fine with Django 1.4:
import shpaml
from django.template.loaders import app_directories
from django.template.base import TemplateDoesNotExist
class Loader(app_directories.Loader):
'''Loads Shpaml templates, see http://shpaml.com
Note: only templates with the .shpaml suffix are procssed'''
is_usable = True
def load_template(self, template_name, template_dirs=None):
if not template_name.endswith('.shpaml'):
raise TemplateDoesNotExist(template_name)
source, origin = self.load_template_source(template_name, template_dirs)
return (shpaml.convert_text(source), origin)
It's not a wrapping loader, but it does work fine for filesystem access:
import shpaml
from django.template.loaders import app_directories, filesystem
from django.template.base import TemplateDoesNotExist
class ShpamlLoaderMixin(object):
def load_template(self, template_name, template_dirs=None):
if not template_name.endswith('.shpaml'):
raise TemplateDoesNotExist(template_name)
source, origin = self.load_template_source(template_name, template_dirs)
return (shpaml.convert_text(source), origin)
class AppDirLoader(ShpamlLoaderMixin, app_directories.Loader):
'''Loads Shpaml templates, see http://shpaml.com/
Note: only templates with the .shpaml suffix are processed'''
is_usable = True
class FilesystemLoader(ShpamlLoaderMixin, filesystem.Loader):
'''Loads Shpaml templates, see http://shpaml.com/
Note: only templates with the .shpaml suffix are processed'''
is_usable = True
I'm pretty confident that the most recent releases with django 1.4 (since I currently have v1.2.x
in production with django 1.4, recently upgraded from v1.1.x
)
It might be that I miss configured something, but it spits out TypeError
template loader settings:
Local vars: