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.

Source Distribution

jinja2schema-0.0.5.tar.gz (16.7 kB view details)

Uploaded Source

File details

Details for the file jinja2schema-0.0.5.tar.gz.

File metadata

File hashes

Hashes for jinja2schema-0.0.5.tar.gz
Algorithm Hash digest
SHA256 c7b5cb3b3930a5a915d401a06f5778fc56616081635728249cf3ac247cceb140
MD5 0c0f956c6fc8948e4f8a95f9093a8d10
BLAKE2b-256 a1e62dd7289f9880a888964c8d312f8aa45ec4dffa6b5b9499dc6aeb507e67dc

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page