skip to navigation
skip to content

Not Logged In

jinja2schema 0.0.1

Type inference for Jinja2 templates.

Latest Version: 0.1.1

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

 
File Type Py Version Uploaded on Size
jinja2schema-0.0.1.tar.gz (md5) Source 2014-07-17 13KB
  • Downloads (All Versions):
  • 15 downloads in the last day
  • 219 downloads in the last week
  • 885 downloads in the last month