Reusable content in templates模板中的可重用内容
Include templates are used to define reusable pieces of code (for example, standard headers, copyright statements, and so on) to be inserted in other templates by means of the 包含模板用于定义通过#parse
directives.#parse
指令插入到其他模板中的可重用代码段(例如,标准头、版权声明等)。
The #parse
directive has the following syntax:#parse
指令具有以下语法:
For example:
Templates that can be referenced in this way in other templates are listed on the Includes tab of the Editor | File and Code Templates page of the IDE settings Ctrl+Alt+S.可以在其他模板中以这种方式引用的模板列在IDE设置Ctrl+Alt+S
的“编辑器”|“文件和代码模板”页面的“包含”选项卡上。
Create an include template创建包含模板
-
In the Settings/Preferences dialog Ctrl+Alt+S, go to .在“设置/首选项”对话框Ctrl+Alt+S中,转到“编辑器”|“文件和代码模板”。 -
Open the Includes tab.打开“包含”选项卡。 -
Click Create Template单击工具栏上的“创建模板”on the toolbar and specify the include template name, extension, and body.
,并指定包含模板名称、扩展名和正文。
Insert a reusable template into another template将可重用模板插入另一个模板
-
Add the添加带有要插入的包含模板名称的#parse
directive with the name of the include template that you want to insert.#parse
指令。For an example, see template syntax.有关示例,请参阅模板语法。