I’m making a Flask app for local development (on a Mac) of HTML templates that will eventually be served through ASP.NET.
For the purposes of local development, I want a way to replace the contents of .NET-style tokens with some data, meaning that Jinja2 would need to be able to recognize %% ... %% tokens in addition to the standard ones: {{ ... }}, <% ... %>, etc.
Everything I’ve found online pertains to the inclusion of some new functionality within the existing tags (e.g. {{ my_custom_function | arg1 arg2 }})
But what about defining a new pattern for tags altogether? Has anyone done this successfully? And will it require modification to the Jinja2 core?
As far as I know, you can use one set for
block_start_stringandblock_end_string, as well as one set forvariable_start_stringandvariable_end_string.From jinja2/environment.py
You can override these with environment variables. Though, I don’t think there is a way to have multiple types recognized. For instance, you can’t have
{{and<%both work, but with a little hackery you certainly could.