Commit e9b7c1b2 authored by Julien Muchembled's avatar Julien Muchembled

jinja2: add many built-in functions from Python

parent 011e2f1c
2.6 (2014-11-26)
================
* jinja2: add many built-in functions from Python.
2.5 (2013-08-07)
======================
================
* Fix file import with Jinja2 >= 2.7
2.4.3 (2013-08-02)
======================
==================
* jinja2: add support for inline templates.
......
from setuptools import setup, find_packages
import os
version = '2.5'
version = '2.6'
name = 'slapos.recipe.template'
long_description = open("README.txt").read() + "\n" + \
open(os.path.join('slapos', 'recipe',
......
......@@ -32,6 +32,12 @@ from jinja2 import Environment, StrictUndefined, \
BaseLoader, TemplateNotFound, PrefixLoader
from contextlib import contextmanager
DEFAULT_CONTEXT = {x.__name__: x for x in (
abs, all, any, bin, bool, callable, chr, complex, dict, divmod,
enumerate, filter, float, format, frozenset, hex, int,
isinstance, iter, len, list, map, max, min, next, oct, ord,
pow, repr, reversed, round, set, sorted, str, sum, tuple, zip)}
_buildout_safe_dumps = getattr(zc.buildout.buildout, 'dumps', None)
DUMPS_KEY = 'dumps'
DEFAULT_IMPORT_DELIMITER = '/'
......@@ -166,7 +172,7 @@ class Recipe(object):
self.rendered = options['rendered']
self.extension_list = [x for x in (y.strip()
for y in options.get('extensions', '').split()) if x]
self.context = context = {}
self.context = context = DEFAULT_CONTEXT.copy()
if _buildout_safe_dumps is not None:
context[DUMPS_KEY] = _buildout_safe_dumps
for line in options.get('context', '').splitlines(False):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment