<commit_before># -*- coding: UTF-8 -*-
'''
    nereid.templating

    Implements the Jinja2 bridge

    :copyright: (c) 2010-2012 by Openlabs Technologies & Consulting (P) Ltd.
    :copyright: (c) 2010 by <NAME>.
    :license: GPLv3, see LICENSE for more details
'''
from decimal import Decimal

from flask.templating import render_template as flask_render_template
from jinja2 import BaseLoader, TemplateNotFound, nodes
from jinja2.ext import Extension
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.MIMEBase import MIMEBase
from email import Encoders

from .contrib import gravatar
from .globals import request
from .helpers import _rst_to_html_filter, make_crumbs


def nereid_default_template_ctx_processor():
    """Add Decimal and make_crumbs to template context"""
    return dict(
        Decimal=Decimal,
        make_crumbs=make_crumbs,
    )


NEREID_TEMPLATE_FILTERS = dict(
    rst = _rst_to_html_filter,
    gravatar = gravatar.url,
)

def render_template(template_name, _prefix_website=True, **context):
    """Renders a template and by default adds the current website
    name as a prefix to the template name thereby allowing automatic
    name conversions from nereid base template to application specific
    templates
    """
    if _prefix_website:
        template_name = '%s/%s' % (
            request.nereid_website.name, template_name
        )
    return flask_render_template(template_name, **context)


class TrytonTemplateLoader(BaseLoader):
    """
    Loaders are responsible for loading templates from a resource.<commit_msg>Remove the gravatar filter #38<commit_after># -*- coding: UTF-8 -*-
'''
    nereid.templating

    Implements the Jinja2 bridge

    :copyright: (c) 2010-2012 by Openlabs Technologies & Consulting (P) Ltd.
    :copyright: (c) 2010 by <NAME>.
    :license: GPLv3, see LICENSE for more details
'''
from decimal import Decimal

from flask.templating import render_template as flask_render_template
from jinja2 import BaseLoader, TemplateNotFound, nodes
from jinja2.ext import Extension
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.MIMEBase import MIMEBase
from email import Encoders

from .globals import request
from .helpers import _rst_to_html_filter, make_crumbs


def nereid_default_template_ctx_processor():
    """Add Decimal and make_crumbs to template context"""
    return dict(
        Decimal=Decimal,
        make_crumbs=make_crumbs,
    )


NEREID_TEMPLATE_FILTERS = dict(
    rst = _rst_to_html_filter,
)

def render_template(template_name, _prefix_website=True, **context):
    """Renders a template and by default adds the current website
    name as a prefix to the template name thereby allowing automatic
    name conversions from nereid base template to application specific
    templates
    """
    if _prefix_website:
        template_name = '%s/%s' % (
            request.nereid_website.name, template_name
        )
    return flask_render_template(template_name, **context)


class TrytonTemplateLoader(BaseLoader):
    """
    Loaders are responsible for loading templates from a resource.
{'fraction_non_alphanumeric': 0.07030264817150063, 'fraction_numerical': 0.011349306431273645, 'mean_word_length': 3.988993710691824, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '7420543', 'n_tokens_mistral': 968, 'n_tokens_neox': 912, 'n_words': 301}