Skip to main content

Type inference for Jinja2 templates.

Project description

https://travis-ci.org/aromanovich/jinja2schema.svg?branch=master

Documentation | GitHub | PyPI

A library for inferring types from Jinja2 templates.

>>> from jinja2schema import infer
>>> s = infer('{{ (x.a.b|first).name }}')
>>> s
{'x': {'a': {'b': [{'name': <scalar>}]}}

>>> s = infer('''
... {% for x in xs %}
...   {{ x }}
... {% endfor %}
''')
>>> s
{'xs': [<scalar>]}
>>> s.to_json_schema()
{
    'type': 'object',
    'required': ['xs'],
    'properties': {
        'xs': {
            'type': 'array'
            'title': 'xs',
            'items': {
                'title': 'x',
                'anyOf': [
                    {'type': 'string'},
                    {'type': 'number'},
                    {'type': 'boolean'},
                    {'type': 'null'}
                ],
            },
        }
    }
}

Installing

pip install jinja2schema

License

BSD license

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for jinja2schema, version 0.0.8
Filename, size File type Python version Upload date Hashes
Filename, size jinja2schema-0.0.8.tar.gz (17.0 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page