What effect does marking a folder as a template folder have in PyCharm?

Viewed 95

In PyCharm, you can go to File-->Settings-->Project-->Project Structure and label folders as being "Template Folders". (See image below.)

What effect does this have?

I searched Google for PyCharm's documentation on this subject but didn't find an explanation.

screenshot of settings project structure

1 Answers

Marking a directory as "Templates" by right-clicking in Project View, or in File > Settings > Project > Project Structure sets the following XML element in your .idea/project.iml file of the /.idea folder.

<component name="TemplatesService">
  <option name="TEMPLATE_CONFIGURATION" value="Jinja2" />
  <option name="TEMPLATE_FOLDERS">
    <list>
      <option value="$MODULE_DIR$/templates_folder" />
    </list>
  </option>
</component>

It's worth mentioning this can go together with selecting a Template Language in File > Settings > Languages & Frameworks > Template Languages. In the above example the <option name="TEMPLATE_CONFIGURATION" value="Jinja2"/> is set there specifically, as shown in the screenshot.

screenshot of settings Template Languages

What this does is inform the IDE where the files are to which some of its specific Template functionalities should be applied, for example Template specific inspections.

I searched Google for PyCharm's documentation on this subject but didn't find an explanation.

Because the exact effects depend on the Template language and Framework being used, different cases will have the IDE use different functionalities. It depends on the specifics, that's why it's hard finding one single answer for this.

Related