Tidy for Jinja2 templates

冷暖自知 提交于 2020-01-03 07:18:50

问题


Is there a tidy-like tool or a tidy configuration, which works fine with Jinja2 templates? The default tidy has problems with Jinja code in attributes and Jinja-loops are formated in an unreadable way. My main requirement is to get the indentation level right. Everything else is nice to have, but not required.


回答1:


You probably want a standalone tool and your question is old, so you've probably already solved it, but just in case this could be helpful. Some editors can handle jinja indent. For example vim with https://github.com/Glench/Vim-Jinja2-Syntax plugin. The '=' command fixes indent. So 'gg=G' fixes indent on all lines. gg to go to the first character; = to fix indent; and G means to the end.




回答2:


While it is not a standalone tool like HTML Tidy, the atom-beautify package for the Atom text editor works fine for me. I use atom-beautify when developing Flask/Jinja2 applications.



来源:https://stackoverflow.com/questions/17124365/tidy-for-jinja2-templates

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