# # Filename: contemplate.py # Revision: 0.1 # # Copyright 2008 Christopher Myers and Justin Davis # # "ConTemplate" # This is by far the fastest python templating language you've ever used. # # You have unlimited license to use this software however you want. There # is no warranty either expressed nor implied. Actually, we recommend not # using it. It just exists to prove a point. # import inspect class ConTemplate(object): def __init__(self, filename): """Load the template""" try: self.template = open(filename).read() except IOError: raise IOError, "No file at that location" def render(self, locs = None): """Render the template""" if not locs: locs = globals() locs.update(inspect.currentframe(1).f_locals) return self.template % locs