def _fn(data, opts): if not type(data) == types.DictType: data = _valueToDict(data) data['_sys'] = opts data['_sys']['templateFile'] = templateFile if templateFile[-6:] == 'django': if not DJANGO_ENABLED: raise PelotonError("DJANGO templates not supported: Django libraries not in path") fp = open(templateFile) template = Template(fp.read()) fp.close() context = Context(data) return template.render(context) else: template = templateLoader.load(templateFile) return template.generate(**data).render()