Python jinja2.ext() Examples

The following are 1 code examples of jinja2.ext(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module jinja2 , or try the search function .
Example #1
Source File: template.py    From vj4 with GNU Affero General Public License v3.0 6 votes vote down vote up
def __init__(self):
    super(Environment, self).__init__(
        loader=jinja2.FileSystemLoader(path.join(path.dirname(__file__), 'ui/templates')),
        extensions=[jinja2.ext.with_],
        auto_reload=options.debug,
        autoescape=True,
        trim_blocks=True,
        undefined=Undefined)
    globals()[self.__class__.__name__] = lambda: self  # singleton

    self.globals['vj4'] = vj4
    self.globals['static_url'] = lambda s: options.cdn_prefix + staticmanifest.get(s)
    self.globals['paginate'] = misc.paginate

    self.filters['nl2br'] = misc.nl2br
    self.filters['markdown'] = misc.markdown
    self.filters['json'] = json.encode
    self.filters['gravatar_url'] = misc.gravatar_url
    self.filters['format_size'] = misc.format_size
    self.filters['format_seconds'] = misc.format_seconds
    self.filters['base64_encode'] = misc.base64_encode