PhpStorm 2024.1 Help

Templates

On this page, configure processing of EJS inclusions, Handlebars expressions, and Mustache templates in PhpStorm.

Before you start

  • Make sure the JavaScript and TypeScript and EJS or Handlebars/Mustache required plugins are enabled on the Settings | Plugins page, tab Installed. For more information, refer to Managing plugins.

Item

Description

Handlebars/Mustache

In this area, configure processing of Handlebars expressions and Mustache templates in PhpStorm. The settings specified on this page apply to dedicated Handlebars and Mustache files that have the extension .hbs or .mustache respectively.

  • Automatically insert closing tag:

    • When this checkbox is selected, PhpStorm automatically inserts the second closing curly brace } of a Handlebars expression as soon as you type the first closing one.

      PhpStorm also recognizes triple stashes {{{ that prevent escaping values inside expressions. In this case, PhpStorm automatically inserts two closing curly braces as soon as you type the first closing one.

    • When this checkbox is cleared, you have to type the closing curly braces and triple stashes manually.

  • Enable formatting:

    • Select this checkbox to have Handlebars expressions and Mustache templates automatically reformatted during code generation, refactoring, or reformatting Ctrl+Alt+L.

    • Clear the checkbox to have the original formatting of Handlebars expressions and Mustache templates preserved.

  • Open HTML files as Handlebars/Mustache:

    • When this checkbox is selected, files with the .html extension are treated as Handlebars/Mustache files so PhpStorm recognizes and processes Handlebars expressions and Mustache templates. The extensions of files remain unchanged but file names are supplied with the fileTypeHandlebars.png icons.

    • When this checkbox is cleared only files with the .hbs extension are treated as Handlebars/Mustache files and Handlebars expressions and Mustache templates within them are recognized and processed.

  • Language for comments: From this list, choose the language to use the style for comments from. When you enter a line or block comment by pressing Ctrl+/ or Ctrl+Shift+/, PhpStorm inserts the comment delimiters that are used in the chosen language, for example:

    • {{!----}} for Handlebars

    • /**/ for JavaScript

    • <!----> for HTML

For more information about Handlebars expressions and Mustache templates, refer to http://handlebarsjs.com/.

The area is only available when the Handlebars/Mustache plugin is installed and enabled. The Handlebars/Mustache plugin is not bundled with PhpStorm, but it can be installed on the Settings | Plugins page, tab Marketplace, as described in Installing plugins from JetBrains Marketplace.

EJS

In this area, specify delimiters for inclusions of EJS in your code. Based on these delimiters, PhpStorm will recognize and process such inclusions correctly. A pair of delimiters is also referred to as execute tag.

  • EJS open delimiter: In this field, type the character string that will indicate the beginning of an EJS inclusion. The default delimiter is <%.

  • EJS close delimiter: In this field, type the character string that will indicate the end of an EJS inclusion. The default delimiter is %>.

Last modified: 25 June 2024