Example #1
0
 def render(self, element=None):
     Widget.render(self)
     f = Kitchen(self.get_form().get_widget_template_dirs(),
                 self.get_form().get_widget_template_extensions())
     f = f.get("select")
     if f:
         t = Template(filename=f)
         return t.render(**self.export())
     return u''
Example #2
0
 def render(self, markup=None):
     Widget.render(self)
     f = Kitchen(self.get_form().get_widget_template_dirs(),
                 self.get_form().get_widget_template_extensions())
     f = f.get('password')
     if f:
         t = Template(filename=f)
         return t.render(**self.export())
     return u''
Example #3
0
 def final(self, name, app_package=True):
     search_dir = app_package and os.path.join(config[self.plugin.app_package]['package_dir']) \
                  or os.path.join(self.plugin.config['package_dir'])
     kitchen = Kitchen(os.path.join(search_dir, 'templates'),
                       ['.mako'])
     template = kitchen.get(name)
     if not template:
         return False
     content = dict()
     for location in self.reqres.content:
         content.setdefault(location, list())
         content[location] = u'\n'.join(self.reqres.content[location])
     t = Template(filename=template, module_directory=config['paths']['template_cache'])
     final = t.render(**content)
     saved = self.reqres.erase_content()
     self.save(final)
     return saved
Example #4
0
 def get_template(self, name, dirs=None, extensions=None):
     dirs = dirs or [os.path.join(self.get_exec_path(), "templates"),
                     os.path.join(self.path, "templates")]
     extensions = extensions or [".mako"]
     k = Kitchen(dirs, extensions)
     return k.get(name)
Example #5
0
 def template(self, name, *args, **kwargs):
     kitchen = Kitchen(os.path.join(self.plugin.config['package_dir'], 'templates'),
                       ['.mako'])
     template = kitchen.get(name)
     t = Template(filename=template, module_directory=config['paths']['template_cache'])
     return t.render(**kwargs)