code
stringlengths
3
6.57k
Template(file=self.filename, **options)
render(self, *args, **kwargs)
kwargs.update(dictarg)
self.context.vars.update(self.defaults)
self.context.vars.update(kwargs)
str(self.tpl)
self.context.vars.clear()
Jinja2Template(BaseTemplate)
prepare(self, filters=None, tests=None, globals={}, **kwargs)
Environment(loader=FunctionLoader(self.loader)
self.env.filters.update(filters)
self.env.tests.update(tests)
self.env.globals.update(globals)
self.env.from_string(self.source)
self.env.get_template(self.filename)
render(self, *args, **kwargs)
kwargs.update(dictarg)
self.defaults.copy()
_defaults.update(kwargs)
self.tpl.render(**_defaults)
loader(self, name)
self.search(name, self.lookup)
open(fname, "rb")
f.read()
decode(self.encoding)
SimpleTemplate(BaseTemplate)
prepare(self, escape_func=html_escape, noescape=False, syntax=None, **ka)
touni(x, enc)
escape_func(touni(x, enc)
co(self)
compile(self.code, self.filename or '<string>', 'exec')
code(self)
open(self.filename, 'rb')
f.read()
touni(source)
depr('Template encodings other than utf8 are no longer supported.')
touni(source, 'latin1')
StplParser(source, encoding=encoding, syntax=self.syntax)
parser.translate()
_rebase(self, _env, _name=None, **kwargs)
_include(self, _env, _name=None, **kwargs)
_env.copy()
env.update(kwargs)
self.__class__(name=_name, lookup=self.lookup)
execute(env['_stdout'], env)
execute(self, _stdout, kwargs)
self.defaults.copy()
env.update(kwargs)
functools.partial(self._include, env)
functools.partial(self._rebase, env)
eval(self.co, env)
env.get('_rebase')
env.pop('_rebase')
join(_stdout)
self._include(env, subtpl, **rargs)
render(self, *args, **kwargs)
env.update(dictarg)
env.update(kwargs)
self.execute(stdout, env)
join(stdout)
StplSyntaxError(TemplateError)
StplParser(object)
strings (trust me, it works)
_re_tok.replace('|\\n','')
Comments (until end of line, but not the newline itself)
block (only start of line)
keyword (but only if it stands alone)
token (only end of line)
statements (may contain python strings)
s((?:%s|[^\'"\n]+?)
__init__(self, source, syntax=None, encoding='utf8')
touni(source, encoding)
self.set_syntax(syntax or self.default_syntax)
get_syntax(self)
string (default: <% %> % {{ }})
set_syntax(self, syntax)
syntax.split()
map(re.escape, self._tokens)
dict(zip(names.split()
re.compile(p%pattern_vars)
property(get_syntax, set_syntax)
translate(self)
RuntimeError('Parser is a one time instance.')
self.re_split.search(self.source[self.offset:])
m.start()
self.text_buffer.append(text)
m.end()
m.group(1)
partition('\n')
self.text_buffer.append(self.source[offs+m.start()
m.start(1)
m.group(2)
len(line+sep)
self.flush_text()
self.read_code(multiline=bool(m.group(4)
self.text_buffer.append(self.source[self.offset:])
self.flush_text()
join(self.code_buffer)
read_code(self, multiline)
self.re_tok.search(self.source[self.offset:])