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
Release history Release notifications
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Filename, size & hash SHA256 hash help | File type | Python version | Upload date |
---|---|---|---|
jinja2schema-0.0.6.tar.gz (16.9 kB) Copy SHA256 hash SHA256 | Source | None | Sep 15, 2014 |