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.4.tar.gz
(16.7 kB
view details)
File details
Details for the file jinja2schema-0.0.4.tar.gz.
File metadata
- Download URL: jinja2schema-0.0.4.tar.gz
- Upload date:
- Size: 16.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c3a181628a9f5ebb843277db95ad199ebb78c34f8b13822c9b3af6b343d17933
|
|
| MD5 |
7582ebc53172cdf105e061921365aa61
|
|
| BLAKE2b-256 |
c86d8e86d94b564ff060257a0fc6187cad644b7e1894e88f2eb55933e5af1720
|