jinja2schema
Demo | Documentation | GitHub | PyPI
A library that provides a heuristic type inference algorithm for Jinja2 templates.
>>> from jinja2schema import infer, to_json_schema
>>> s = infer('{{ (x.a.b|first).name }}')
>>> s
{'x': {'a': {'b': [{'name': <scalar>}]}}
>>> s = infer('''
... {% for x in xs %}
... {{ x }}
... {% endfor %}
''')
>>> s
{'xs': [<scalar>]}
>>> to_json_schema(s)
{
'type': 'object',
'required': ['xs'],
'properties': {
'xs': {
'type': 'array'
'title': 'xs',
'items': {
'title': 'x',
'anyOf': [
{'type': 'string'},
{'type': 'number'},
{'type': 'boolean'},
{'type': 'null'}
],
},
}
}
}
More examples can be found at the demo page.
Installing
pip install jinja2schema
License
Metadata
Release files for jinja2schema 0.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| jinja2schema-0.1.4.tar.gz | 19.8 kB | Details |
Release files / jinja2schema-0.1.4.tar.gz
| Download URL | jinja2schema-0.1.4.tar.gz |
|---|---|
| Size | 19.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
236e4ee6612a0ab5a5664c453c954a2c7e42b6be986c12f7b31f34f9082043bc
|
|
BLAKE2b-256 checksum How to use checksums |
606f8db433c9b644654f77a5a85a251298b278b6fefe668c1d856ad34c61c811
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |