Commit 7f6da416 by Pieter van de Bruggen

Handling partial indentation.

parent be3d02d9
...@@ -15,11 +15,13 @@ def call(view, x, template=None): ...@@ -15,11 +15,13 @@ def call(view, x, template=None):
x = x(view, template) x = x(view, template)
return unicode(x) return unicode(x)
def partialTag(name): def partialTag(name, indentation=''):
def func(self): def func(self):
tmpl = Template(self.partial(name)) nonblank = re.compile(r'^(.)', re.M)
tmpl.view = self template = re.sub(nonblank, indentation + r'\1', self.partial(name))
parsed = tmpl._parse() template = Template(template)
template.view = self
parsed = template._parse()
return ''.join(map(call, [self] * len(parsed), parsed)) return ''.join(map(call, [self] * len(parsed), parsed))
return func return func
...@@ -158,7 +160,7 @@ class Template(object): ...@@ -158,7 +160,7 @@ class Template(object):
self.otag, self.ctag = name.split() self.otag, self.ctag = name.split()
self._compile_regexps() self._compile_regexps()
elif captures['tag'] == '>': elif captures['tag'] == '>':
buffer.append(partialTag(name)) buffer.append(partialTag(name, captures['whitespace']))
elif captures['tag'] in ['#', '^']: elif captures['tag'] in ['#', '^']:
try: try:
self._parse(template, name, pos) self._parse(template, name, pos)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment