WebStorm 2023.3 Help

Handlebars and Mustache

With WebStorm, you can use Handlebars expressions and Mustache templates in hbs or mustache files. WebStorm processes contents of such files according to default or custom settings specified on the Templates page of the Settings dialog.

Before you start

  • Make sure the Handlebars/Mustache plugin is enabled in the settings. Press Ctrl+Alt+S to open the IDE settings and then select Plugins. Click the Installed tab. In the search field, type Handlebars/Mustache. For more information about plugins, refer to Managing plugins.

Configuring Handlebars and Mustache in WebStorm

  1. In the Settings dialog (Ctrl+Alt+S) , go to Languages & Frameworks | JavaScript | Templates.

  2. On the Templates page that opens, switch to the Handlebars/Mustache area.

  3. To automatically insert the second closing curly brace } of a Handlebars expression on typing the first closing one, select the Automatically insert closing tag checkbox.

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

  4. To automatically reformat Handlebars expressions and Mustache templates on code generation, refactoring, or pressingCtrl+Alt+L, select the Enable formatting checkbox. Otherwise, WebStorm always keeps their original formatting.

  5. Choose the language to use the style for comments from. When you enter a line or block comment by pressing Ctrl+/ or Ctrl+Shift+/, WebStorm inserts the comment delimiters that are used in the chosen language, for example:

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

    • /**/ for JavaScript

    • <!----> for HTML

  6. To configure Handlebars/Mustache-aware syntax highlighting, in the Settings dialog (Ctrl+Alt+S) , go to Editor | Color Scheme | Handlebars/Mustache. Select the color scheme, accept the highlighting settings inherited from defaults or customize them as described in Configuring Colors and Fonts.

Last modified: 20 February 2024