Jinja, get line of source code after template rendering

社会主义新天地 提交于 2019-12-12 12:32:37

问题


Is it possible to get line of source code for each line of rendered template?

For example if we have template like below:

some_expr
{% if true %}
    other_expr        
{% endif %}

So, after template rendering following text is produced:

some_expr    
other_expr

I want to get information that 'some_expr' is produced from 1st line of template source code, and 'other_expr' if produced from 3rd line. Even better if I can get file name and line from which rendered line is produced (in case of including other templates).

If it is possible with some other template engine (not necessary python) it is also a good solution for me.

来源:https://stackoverflow.com/questions/33823159/jinja-get-line-of-source-code-after-template-rendering

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!