Index: sitescripts/cms/converters.py |
=================================================================== |
--- a/sitescripts/cms/converters.py |
+++ b/sitescripts/cms/converters.py |
@@ -126,7 +126,7 @@ |
return converter() |
raise Exception("Failed to resolve include %s in page %s" % (name, self._params["page"])) |
- return re.sub(r'<\?\s*include\s+([^\s<>"]+)\s*\?>', resolve_include, text) |
+ return re.sub(r'(?:<|\<\;)\?\s*include\s+([^\s<>"]+)\s*\?(?:>|\>\;)', resolve_include, text) |
Wladimir Palant
2013/12/12 12:51:06
Nope, we really don't want to do this in raw HTML
Sebastian Noack
2013/12/12 13:54:39
I agree that we should do that only for markdown.
Wladimir Palant
2013/12/13 14:01:45
The other regexp applied to processing instruction
|
def __call__(self): |
result = self.get_html(self._params[self._key]) |
@@ -172,6 +172,16 @@ |
return result |
class TemplateConverter(Converter): |
+ class _SourceLoader(jinja2.BaseLoader): |
+ def __init__(self, source): |
+ self.source = source |
+ |
+ def get_source(self, environment, template): |
+ try: |
+ return self.source.read_file(template + ".tmpl"), None, None |
+ except Exception: |
+ raise jinja2.TemplateNotFound(template) |
+ |
def __init__(self, *args, **kwargs): |
Converter.__init__(self, *args, **kwargs) |
@@ -197,7 +207,7 @@ |
filters[func] = getattr(module, func) |
filters[func].module_ref = module # Prevent garbage collection |
- self._env = get_custom_template_environment(filters) |
+ self._env = get_custom_template_environment(filters, self._SourceLoader(self._params["source"])) |
def get_html(self, source): |
template = self._env.from_string(source) |