Browse Source

Now the template renders from a string

main
Lakshmi Vyasarajan 14 years ago
parent
commit
9f2cf604c5
3 changed files with 5 additions and 5 deletions
  1. +1
    -1
      hyde/engine.py
  2. +2
    -2
      hyde/ext/templates/jinja.py
  3. +2
    -2
      hyde/template.py

+ 1
- 1
hyde/engine.py View File

@@ -98,7 +98,7 @@ class Engine(Application):
if page.source_file.is_text:
logger.info("Rendering [%s]", page)
context.update(page=page)
text = template.render(page, context)
text = template.render(page.source_file.read_all(), context)
target.write(text)
else:
logger.info("Copying binary file [%s]", page)

+ 2
- 2
hyde/ext/templates/jinja.py View File

@@ -49,9 +49,9 @@ class Jinja2Template(Template):
self.env.globals['media_url'] = media_url
self.env.globals['content_url'] = content_url

def render(self, resource, context):
def render(self, text, context):
"""
Renders the given resource using the context
"""
template = self.env.get_template(resource.relative_path)
template = self.env.from_string(text)
return template.render(context)

+ 2
- 2
hyde/template.py View File

@@ -19,9 +19,9 @@ class Template(object):
"""
abstract

def render(self, resource, context):
def render(self, text, context):
"""
Given the resource, and the context, this function
Given the text, and the context, this function
must return the rendered string.
"""
abstract

||||||
x
 
000:0
Loading…
Cancel
Save