Type inference for Jinja2 templates.
Project description
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
Project details
Release history Release notifications | RSS feed
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.8.tar.gz
(17.0 kB
view details)
File details
Details for the file jinja2schema-0.0.8.tar.gz
.
File metadata
- Download URL: jinja2schema-0.0.8.tar.gz
- Upload date:
- Size: 17.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 58c9dc0d6314ec4b0ea44ea91d4c7fd8e98344edd99d3e927b61b9ffbb84a3ce |
|
MD5 | 859f37fd19239daad44d381575a31a62 |
|
BLAKE2b-256 | a9863559033ec08d2d19319a91b1bc0f08df840d0c327d2843ffc41d59f9125f |