black icon indicating copy to clipboard operation
black copied to clipboard

Support for formatting jinja templates

Open ryanwalder opened this issue 5 years ago • 4 comments

Given Jinja is a templating language for Python it would be nice if Black could format Jinja templates as well.

Main use case: Formatting the jinja/yaml sls format used by Salt which can get very jinja heavy.

ryanwalder avatar Jun 28 '20 15:06 ryanwalder

I also have a use case

H3Atom avatar Aug 29 '20 12:08 H3Atom

This also impacts cookiecutter templates for Python projects

ScriptAutomate avatar Mar 26 '21 20:03 ScriptAutomate

I am writing a cookiecutter template and would very much like to use black to format our code. Is any update on this issue?

alyssweissglass avatar Jan 04 '23 21:01 alyssweissglass

No update. This is rather low priority for us maintainers. We would love external contributions though!

ichard26 avatar Jan 05 '23 19:01 ichard26

I think this is out of scope for this project. Jinja is different enough from Python that this is best explored in another tool.

hauntsaninja avatar Aug 04 '23 02:08 hauntsaninja

I am writing a cookiecutter template and would very much like to use black to format our code. Is any update on this issue?

Hey @alyssweissglass and @ScriptAutomate. We stumbled across the same issue and decided to be pragmatic about it. We are using a post gen hook to format the output of cookiecutter. Obviously, this does not fix the root cause of the issue, but at least we are not creating projects containing invalidly formatted code any more. Also works like a charm with cruft and cruft update in particular.

siyb avatar Aug 29 '23 13:08 siyb