New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Jinja Template Support #5754
Comments
I'm interested in creating a plugin to support Nunjucks (which essentially has the same syntax as Jinja) - so could be shared between the two. It was pretty easy to parse the a Nunjucks template into AST - however the "HTML" parts aren't parsed at all. They are just "TemplateObject" nodes which could contain the likes of: Reading this #5286 (comment), it appears as though it could be possible to replace the Nunjucks/Jinja block tags However, upon replacing the placeholders, I'd obviously like to format the block tags themselves. I'm still not really familiar with how Prettier's Many thanks! |
Did you mean that you'd like to format those Jinja tags yourself? Of course you can, though it may not be that intuitive but you can definitely control the output yourself.
I'm not sure how to describe the process, I hope the following section could answer your question:
|
Okay cool - I've managed to get something working using the placeholder technique. Thanks for your help @ikatyang. Any visitors arriving via a search, I've started a repo here: https://github.com/justrhysism/prettier-plugin-nunjucks Long road ahead. Contributions welcome. |
For other Google travelers in search of a solution, I've found that sticking with the standard Prettier HTML formatting mostly works, and for the specific lines where it doesn't, the ignore flag is your friend. It will not format the first tag following this comment:
|
@brittohalloran This is an OK solution but you dont really want to add the |
This would open up prettier to a new class of users... just sayin'...
|
This should be a plugin. Closing. |
Please add Jinja support, I agree that using |
You can create plugin |
Yes I see what you mean, haven't fiddled with creating plugins before for this purpose, I guess I'll need to figure it out
|
Jinja is an extremely popular Python templating framework. It is used by many projects including Mozilla and Instagram.
http://jinja.pocoo.org
An example of its syntax
The text was updated successfully, but these errors were encountered: