Created
October 9, 2011 14:46
-
-
Save jacobh/1273767 to your computer and use it in GitHub Desktop.
template class
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Exception: | |
NameError("global name 'render' is not defined",) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Template: | |
from pystache import render | |
from settings import template_dir | |
dir = template_dir | |
def __init__(self, name, context): | |
self.name = name | |
self.context = context | |
def render(self): | |
f = open(self.dir + '/' + self.name + '.html', 'r').read() | |
r = render(f, self.context) | |
return r |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from functions import Template | |
t = Template('login', {}) | |
t.render() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment