Commit 06d0b3e1 by Chris Jerdonek

Got partials working.

parent e29f92b8
...@@ -120,7 +120,7 @@ class RenderEngine(object): ...@@ -120,7 +120,7 @@ class RenderEngine(object):
_template.to_unicode = self.literal _template.to_unicode = self.literal
_template.escape = self.escape _template.escape = self.escape
_template.partial = self.load_partial _template.get_partial = self.load_partial
return _template.render_template(template=template, context=context) return _template.render_template(template=template, context=context)
...@@ -386,8 +386,12 @@ class Template(object): ...@@ -386,8 +386,12 @@ class Template(object):
def escape(self, text): def escape(self, text):
return cgi.escape(text, True) return cgi.escape(text, True)
def partial(self, name, context=None): def get_partial(self, name):
return context.partial(name) pass
def _render_partial(self, name, context):
template = self.get_partial(name)
return self.render_template(template, context)
def _get_string_value(self, context, tag_name): def _get_string_value(self, context, tag_name):
""" """
...@@ -421,7 +425,6 @@ class Template(object): ...@@ -421,7 +425,6 @@ class Template(object):
return val return val
def escape_tag_function(self, name): def escape_tag_function(self, name):
get_literal = self.literal_tag_function(name) get_literal = self.literal_tag_function(name)
def func(context): def func(context):
...@@ -441,7 +444,7 @@ class Template(object): ...@@ -441,7 +444,7 @@ class Template(object):
def partial_tag_function(self, name, indentation=''): def partial_tag_function(self, name, indentation=''):
def func(context): def func(context):
nonblank = re.compile(r'^(.)', re.M) nonblank = re.compile(r'^(.)', re.M)
template = re.sub(nonblank, indentation + r'\1', self.partial(name, context)) template = re.sub(nonblank, indentation + r'\1', self._render_partial(name, context))
return self.render_template(template, context) return self.render_template(template, context)
return func return func
...@@ -476,7 +479,7 @@ class Template(object): ...@@ -476,7 +479,7 @@ class Template(object):
template.ctag = delims[1] template.ctag = delims[1]
template.escape = self.escape template.escape = self.escape
template.partial = self.partial template.get_partial = self.get_partial
template.to_unicode = self.to_unicode template.to_unicode = self.to_unicode
template._compile_regexps() template._compile_regexps()
......
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