<commit_before>"""Rueckenwind tempating

Rueckenwind does not contain it's own templating engine
but is based on Jinja2.

Added methods inside functions:
 * url_for
 * handler
"""
import jinja2

import rw.http


def create_template_env(pkgs):
    loaders = [jinja2.PackageLoader(pkg, 'templates') for pkg in pkgs]
    template_env = jinja2.Environment(
        loader=jinja2.ChoiceLoader(loaders),
        extensions=['jinja2.ext.loopcontrols',
                    'jinja2.ext.i18n'],
    )
    template_env.globals['url_for'] = rw.http.url_for

    # some more default functions
    # template_env.globals['enumerate'] = enumerate
    # template_env.globals['isinstance'] = isinstance
    # template_env.globals['len'] = len
    # # default types
    # template_env.globals['int'] = int
    # template_env.globals['str'] = str
    # template_env.globals['unicode'] = unicode
    # template_env.globals['list'] = list
    # template_env.globals['tuple'] = tuple
    # template_env.globals['dict'] = dict
    # template_env.globals['set'] = set
    # template_env.globals['basestring'] = basestring
    # template_env.globals['urlencode'] = urlencode
    # filter
    # template_env.filters['json'] = dumps
    return template_env<commit_msg>tempalte: add back json filter<commit_after>"""Rueckenwind tempating

Rueckenwind does not contain it's own templating engine
but is based on Jinja2.

Added methods inside functions:
 * url_for
 * handler
"""
import json

import jinja2

import rw.http


def create_template_env(pkgs):
    loaders = [jinja2.PackageLoader(pkg, 'templates') for pkg in pkgs]
    template_env = jinja2.Environment(
        loader=jinja2.ChoiceLoader(loaders),
        extensions=['jinja2.ext.loopcontrols',
                    'jinja2.ext.i18n'],
    )
    template_env.globals['url_for'] = rw.http.url_for
    template_env.filters['json'] = json.dumps

    # some more default functions
    # template_env.globals['enumerate'] = enumerate
    # template_env.globals['isinstance'] = isinstance
    # template_env.globals['len'] = len
    # # default types
    # template_env.globals['int'] = int
    # template_env.globals['str'] = str
    # template_env.globals['unicode'] = unicode
    # template_env.globals['list'] = list
    # template_env.globals['tuple'] = tuple
    # template_env.globals['dict'] = dict
    # template_env.globals['set'] = set
    # template_env.globals['basestring'] = basestring
    # template_env.globals['urlencode'] = urlencode
    # filter

    return template_env
{'fraction_non_alphanumeric': 0.1212241653418124, 'fraction_numerical': 0.007154213036565978, 'mean_word_length': 3.6697588126159553, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2795361', 'n_tokens_mistral': 834, 'n_tokens_neox': 808, 'n_words': 157}