def cook(self, body): PageTemplateFile.cook(self, body) if self.macro: # render only the portion of the template included in a # define-macro named the value of self.macro macro_renderer = self.macros[self.macro].include self._render = macro_renderer
def template(self): tf = PageTemplateFile( self.path, auto_reload=self.lookup.auto_reload, debug=self.lookup.debug, translate=self.lookup.translate ) if self.macro: # render only the portion of the template included in a # define-macro named the value of self.macro macro_renderer = tf.macros[self.macro].include tf._render = macro_renderer return tf
def template(self): tf = PageTemplateFile(self.path, auto_reload=self.lookup.auto_reload, debug=self.lookup.debug, translate=self.lookup.translate) if self.macro: # render only the portion of the template included in a # define-macro named the value of self.macro macro_renderer = tf.macros[self.macro].include tf._render = macro_renderer return tf
def template(self): if sys.platform.startswith("java"): # pragma: no cover raise RuntimeError("Chameleon templates are not compatible with Jython") tf = PageTemplateFile( self.path, auto_reload=self.lookup.auto_reload, debug=self.lookup.debug, translate=self.lookup.translate ) if self.macro: # render only the portion of the template included in a # define-macro named the value of self.macro macro_renderer = tf.macros[self.macro].include tf._render = macro_renderer return tf
def template(self): if sys.platform.startswith('java'): # pragma: no cover raise RuntimeError( 'Chameleon templates are not compatible with Jython') tf = PageTemplateFile(self.path, auto_reload=self.lookup.auto_reload, debug=self.lookup.debug, translate=self.lookup.translate) if self.macro: # render only the portion of the template included in a # define-macro named the value of self.macro macro_renderer = tf.macros[self.macro].include tf._render = macro_renderer return tf
def template(self): if sys.platform.startswith('java'): # pragma: no cover raise RuntimeError( 'Chameleon templates are not compatible with Jython') return PageTemplateFile(self.path, auto_reload=self.lookup.auto_reload, debug=self.lookup.debug, translate=self.lookup.translate)
def load(self, filename): for path in self.search_path: path = os.path.join(path, filename) if (path in self.notexists) and (not self.auto_reload): raise mako.exceptions.TopLevelLookupException( "Can not find template %s" % filename) try: return PageTemplateFile(path, parser=self.parser, auto_reload=self.auto_reload, encoding='utf-8') except OSError: self.notexists[path] = True raise mako.exceptions.TopLevelLookupException( "Can not find template %s" % filename)
def load(self, filename): for path in self.search_path: path = os.path.join(path, filename) if (path in self.notexists) and (not self.auto_reload): raise TemplateError("Can not find template %s" % filename) try: return PageTemplateFile(path, parser=self.parser, auto_reload=self.auto_reload, debug=self.debug, encoding=self.encoding, translate=self.translate) except OSError: self.notexists[path] = True raise TemplateError("Can not find template %s" % filename)
def render(self, *args, **kw): if args: slots, = args return self.render_macro("", slots=slots, parameters=kw) kw.update(self._bound_kwargs) return PageTemplateFile.render(self, **kw)
def __init__(self, relative_path, path): SkinObject.__init__(self, relative_path, path) PageTemplateFile.__init__(self, path)
isinstance(node.func, ast.Name): if node.func.id == KEY: arg = node.args[0] assert isinstance(arg, ast.Str) arg = arg.s print "{0}({1!r})".format(KEY, arg) elif node.func.id == KEY_PL: args = node.args[:2] for i in args: assert isinstance(i, ast.Str) print "{0}({1!r}, {2!r})".format(KEY_PL, args[0].s, args[1].s) class XgettextPythonExpr(PythonExpr): def parse(self, string): extract_msg(string) return super(self.__class__, self).parse(string) PageTemplateFile.expression_types['python'] = XgettextPythonExpr if __name__ == '__main__': try: while True: fname = raw_input() print '#', fname template = PageTemplateFile(fname) template.cook_check() except EOFError: pass
def setFromFilename(self, filename, _prefix=None): self._filename = filename self._prefix = _prefix self._template = PageTemplateFile(os.path.join(_prefix, filename)) return
def render(self, **context): return PageTemplateFile.render(self, **context)
def get_pt(self, text): f = open(self.TEMPFILENAME, "wb") f.write(text) f.close() pt = PageTemplateFile(self.TEMPFILENAME) return pt