Jinja2 Code Style settings in PyCharm 3.0

  • 3
  • 21

I have selected Jinja2 as my python template language but I don't see Jinja2 as an option under "Settings - Code Style". This seems to be a regression from v2.x. I realize I may be missing some key setting that enables Jinja2 styling but it really shouldn't be that tricky.

My preference would be to have the flexibility to set the code styles for any supported template language whether or not they are currently active in a project.
I was informed the template for the underlying language is used... no separate code styles for the template language itself. Makes sense... but I still believe there is a problem.

I have HTML set to indent & tab size by 2 but consistently get a tab of 4 in Jinja2 templates (with .html extensions) while plain html files correctly tab by 2. Note that auto indent (of 2) works correctly in Jinja2 templates but tab size does not!

It's easy to test... I have the ".html" file extension mapped to Jinja2 and ".htm" remains as plain html.
I create two new test files:
test.htm (which is treated as plain HTML)
test.html (which is treated as Jinja2)

The former (test.htm) tabs correctly by 2 while the latter (test.html) tabs by 4. I see no way I can change this behavior.... v2.x did NOT behave this way for me.

Hi Doug,

please, remove html extension mapping in Settings->File Types->Jinja2 templates.
File type association for template languages should be already done for html, xhtml and xml types in Settings->Python Template Languages
If it doesn't help, please, file a bug report in our tracker so we can take a closer look at the issue.

Removing the html file mapping fixed it! Thanks!