jinja2-error

Jinja2 Extension for Raise Error


Keywords
jinja2, extension, error
License
MIT
Install
pip install jinja2-error==0.1.0

Documentation

Jinja2 Error

PyPI Package PyPI Python Versions PyPI Package License

Jinja2 Extension for Raise Error

Installation

jinja2_error is available for download from PyPI via pip:

$ pip install jinja2_error

It will automatically install jinja2 along with arrow.

Usage

Error Tag

The extension comes with a error tag that provides convenient to raise error.

from jinja2 import Environment

from jinja2_error import jinja2_error

if __name__ == '__main__':
    env = Environment(extensions=[jinja2_error.ErrorExtension])
    render_text = """
            {% if 1==1 %}
              {% error "It's error" %}
            {% endif %}
            """
    template = env.from_string(render_text)
    result = template.render({"a": "b"})

If you use it with ansible template:

ANSIBLE_JINJA2_EXTENSIONS=jinja2_error.ErrorExtension ansible-playbook site.yml -vvv

Issues

If you encounter any problems, please file an issue along with a detailed description.

Code of Conduct

Everyone interacting in the jinja2_error project's codebases, issue trackers, chat rooms, and mailing lists is expected to follow the PyPA Code of Conduct.

License

Distributed under the terms of the MIT license, jinja2_error is free and open source software

OSI certified