diff genshi/template/text.py @ 610:6a37018199fd

* XInclude elements in markup templates now support the `parse` attribute; when set to "xml" (the default), the include is processed as before, but when set to "text", the included template is parsed as a text template using the new syntax (ticket #101). * If an include is found when parsing a template, but no template loader has been specified, a `TemplateSyntaxError` is raised.
author cmlenz
date Mon, 27 Aug 2007 23:20:47 +0000
parents 237050080827
children cae74e2637c6
line wrap: on
line diff
--- a/genshi/template/text.py
+++ b/genshi/template/text.py
@@ -28,7 +28,8 @@
 
 import re
 
-from genshi.template.base import BadDirectiveError, Template, EXEC, INCLUDE, SUB
+from genshi.template.base import BadDirectiveError, Template, \
+                                 TemplateSyntaxError, EXEC, INCLUDE, SUB
 from genshi.template.eval import Suite
 from genshi.template.directives import *
 from genshi.template.directives import Directive, _apply_directives
@@ -186,8 +187,12 @@
             command, value = mo.group(2, 3)
 
             if command == 'include':
+                if self._include not in self.filters:
+                    raise TemplateSyntaxError('Include found but no template '
+                                              'loader specified', self.filepath,
+                                              lineno)
                 pos = (self.filename, lineno, 0)
-                stream.append((INCLUDE, (value.strip(), []), pos))
+                stream.append((INCLUDE, (value.strip(), None, []), pos))
 
             elif command == 'python':
                 if not self.allow_exec:
@@ -306,8 +311,12 @@
                     stream[start_offset:] = [(SUB, ([directive], substream),
                                               (self.filepath, lineno, 0))]
             elif command == 'include':
+                if self._include not in self.filters:
+                    raise TemplateSyntaxError('Include found but no template '
+                                              'loader specified', self.filepath,
+                                              lineno)
                 pos = (self.filename, lineno, 0)
-                stream.append((INCLUDE, (value.strip(), []), pos))
+                stream.append((INCLUDE, (value.strip(), None, []), pos))
             elif command != '#':
                 cls = self._dir_by_name.get(command)
                 if cls is None:
Copyright (C) 2012-2017 Edgewall Software