Hello. I want to use Jinja2 in my program, but I don’t need such features as block inclusion and template inheritance. Is it possible to make the Jinja API syntax {% block ...%}, {% extends ...%}, {% include ...%} ignored?
1 answer
It seems that there is no official way, but you can go for a hack, which is that in the jinja2.parser module there is a declaration of the _statement_keywords variable, which contains many types of blocks. In source code, this variable is equal to
_statement_keywords = frozenset(['for', 'if', 'block', 'extends', 'print', 'macro', 'include', 'from', 'import', 'set']) If you change the value of this variable to
_statement_keywords = frozenset(['for', 'if', 'set']) This is what I need.
|