from jinja2 import Environment, DictLoader


def render(template, mapping):
    """
    Render template document aginst mapping dictionary with jinja2.

    :param str template:
    :param dict mapping:
    :return:
    :rtype: str
    """

    env = Environment(loader=DictLoader({
        'cfn': str(template)
    }))
    tpl = env.get_template('cfn')

    return tpl.render(mapping)