Dávid Veszelovszki Dávid Veszelovszki - 4 months ago 16
Twig Question

Trying to enable XML language in Twig templates in PhpStorm

In my project I have

files that render XML using the Twig templating engine. Anyone figured out how to enable both XML and Twig code support at the same time in PhpStorm?

I tried
Settings -> File Types
, but only one type can be applied to a file type at a time. The funny thing is, if I change settings, there is a few seconds when PhpStorm is reindexing the project and both XML and Twig rules are applied to a file, but when it finishes reindexing, it removes one of the languages.

I also thought about language injections, but that feature seems to only work with strings.

  1. Settings/Preferences | Languages & Frameworks | Template Data Languages

  2. Find your file(s) there and assign XML in right column (can also be applied to the whole folder -- all files and sub folders will inherit this setting).

This will make XML as primary outer language instead of default HTML.