Skip to content

Instantly share code, notes, and snippets.

@jacobh
Created October 9, 2011 14:46
Show Gist options
  • Save jacobh/1273767 to your computer and use it in GitHub Desktop.
Save jacobh/1273767 to your computer and use it in GitHub Desktop.
template class
Exception:
NameError("global name 'render' is not defined",)
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
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