Templates with multiple files
Some programming patterns and frameworks require a set of related files, usually with a very specific structure. For example, a web component can consist of a Python module, an HTML template, a style sheet, and a JavaScript file stored in one folder.
In PyCharm, you can create sets of related files by adding child templates to a file template. When you create a file from such a template, it will also create files from child templates.
Create a template with multiple files
In the Settings dialog (Ctrl+Alt+S) , select .
Create the main file template.
On the Files tab, click
and specify the name, file extension, and body of the template.
Select the new template in the list and click
on the toolbar. Specify the name, file extension, and body of the child template.
Example: Template for a folder with several files
Suppose you want to create a header folder with the header.py, header.html, header.css, and header.js files in it.
In the Settings dialog (Ctrl+Alt+S) , select .
Create the main template for the Python file:
On the Files tab, click
(Create Template).
In the Name field, type
Component folder. In the Extension field, typepy.In the File name field, type
$NAME/$NAME. The part before the slash is the name of the folder, the part after the slash is the name of the file in it.Optionally, add the template body, for example:
# Created by ${USER} on ${DATE}
Add a child template for each of the other files:
Select the Component folder template in the list and click
(Create Child Template File).
In the File name field, type
$NAME/$NAME. In the Extension field, typehtml.Repeat these steps to add child templates with the
cssandjsextensions.
Click OK to save the templates.
In the Project tool window, right-click the directory where you want to create the folder and select .
In the dialog that opens, type
headerand click OK.PyCharm creates the header folder with four files in it.