Mercurial > genshi > mirror
comparison genshi/template/text.py @ 703:af57b12e3dd2 experimental-match-fastpaths
merge in trunk up through r818 - fundamentally changed the way MatchSet works, but actually is more consistent now
author | aflett |
---|---|
date | Mon, 31 Mar 2008 22:47:50 +0000 |
parents | 3ed5d7e47f38 |
children | d143dd73789b |
comparison
equal
deleted
inserted
replaced
701:52a597419c0d | 703:af57b12e3dd2 |
---|---|
26 new syntax to remain compatible with future Genshi releases. | 26 new syntax to remain compatible with future Genshi releases. |
27 """ | 27 """ |
28 | 28 |
29 import re | 29 import re |
30 | 30 |
31 from genshi.core import TEXT | |
31 from genshi.template.base import BadDirectiveError, Template, \ | 32 from genshi.template.base import BadDirectiveError, Template, \ |
32 TemplateSyntaxError, EXEC, INCLUDE, SUB | 33 TemplateSyntaxError, EXEC, INCLUDE, SUB |
33 from genshi.template.eval import Suite | 34 from genshi.template.eval import Suite |
34 from genshi.template.directives import * | 35 from genshi.template.directives import * |
35 from genshi.template.directives import Directive, _apply_directives | 36 from genshi.template.directives import Directive |
36 from genshi.template.interpolation import interpolate | 37 from genshi.template.interpolation import interpolate |
37 | 38 |
38 __all__ = ['NewTextTemplate', 'OldTextTemplate', 'TextTemplate'] | 39 __all__ = ['NewTextTemplate', 'OldTextTemplate', 'TextTemplate'] |
39 __docformat__ = 'restructuredtext en' | 40 __docformat__ = 'restructuredtext en' |
40 | 41 |
186 lineno += len(source[start:end].splitlines()) | 187 lineno += len(source[start:end].splitlines()) |
187 command, value = mo.group(2, 3) | 188 command, value = mo.group(2, 3) |
188 | 189 |
189 if command == 'include': | 190 if command == 'include': |
190 pos = (self.filename, lineno, 0) | 191 pos = (self.filename, lineno, 0) |
191 stream.append((INCLUDE, (value.strip(), None, []), pos)) | 192 value = list(interpolate(value, self.basedir, self.filename, |
193 lineno, 0, lookup=self.lookup)) | |
194 if len(value) == 1 and value[0][0] is TEXT: | |
195 value = value[0][1] | |
196 stream.append((INCLUDE, (value, None, []), pos)) | |
192 | 197 |
193 elif command == 'python': | 198 elif command == 'python': |
194 if not self.allow_exec: | 199 if not self.allow_exec: |
195 raise TemplateSyntaxError('Python code blocks not allowed', | 200 raise TemplateSyntaxError('Python code blocks not allowed', |
196 self.filepath, lineno) | 201 self.filepath, lineno) |