Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Integrating Nunjucks with IntelliJ IDEA / Webstorm

How can I add syntax highlighting to Nunjucks template files in IntelliJ IDEA / Webstorm?

There is no obvious plugin available. Perhaps there is something for a similar templating engine that would work?

like image 731
JoshuaDavid Avatar asked Nov 06 '15 02:11

JoshuaDavid


People also ask

Does WebStorm support nunjucks?

It's a template engine with similar syntax (but for PHP). Add the custom pattern *.njk. Now all *.njk files are parsed as Twig so in the end you have support for Nunjucks. Show activity on this post. Webstorm don't has build-in TWIG support.

Should I use WebStorm or IntelliJ IDEA?

All of the functionality in WebStorm is available in IntelliJ IDEA Ultimate, either out of the box or via free plugins. There's no need to purchase licenses for both IntelliJ IDEA Ultimate and WebStorm unless you like having a dedicated tool for each language. Then WebStorm may be the right choice for focused JavaScript development.

Does IntelliJ IDEA support Linux?

Currently, it supports several Linux distributions, such as Ubuntu, OpenSUSE, and SLES. IntelliJ IDEA lets you create and open projects in the WSL file system, run, and debug applications in the WSL environment. You can also use local Windows-based projects and run the applications remotely in WSL with the run targets feature.

How do I run WSL in IntelliJ IDEA?

If you open the run configuration, note that IntelliJ IDEA refers to WSL as local machine. The results of the code execution are displayed in the Run tool window. To run Terminal in WSL configuration, open project Settings/Preference ( Ctrl+Alt+S) and go to Tools | Terminal. Type wsl.exe in the Shell path field and click Ok.


1 Answers

Just found a solution. Configure a custom extension with Twig files. It's a template engine with similar syntax (but for PHP).

  1. add Twig Support plugin if necessary

  2. Go to Settings -> Editor -> File Types and add find Twig

  3. Add the custom pattern *.njk.

Now all *.njk files are parsed as Twig so in the end you have support for Nunjucks.

like image 113
JoshuaDavid Avatar answered Sep 21 '22 09:09

JoshuaDavid