# How to change precedence when injecting language

**URL:** <https://platform.jetbrains.com/t/how-to-change-precedence-when-injecting-language/929>\
**Category:** IntelliJ Platform\
**Tags:** language-injection\
**Created:** [March 14, 2025, 4:56pm UTC](https://platform.jetbrains.com/t/how-to-change-precedence-when-injecting-language/929 "2025-03-14T16:56:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tarik.weiss](https://avatars.discourse-cdn.com/v4/letter/t/3ab097/32.png) [@tarik.weiss](https://platform.jetbrains.com/u/tarik.weiss)\
**Post date:** [March 14, 2025, 4:56pm UTC](https://platform.jetbrains.com/t/how-to-change-precedence-when-injecting-language/929/1 "2025-03-14T16:56:16Z")

</div>

I want to inject PHP into YAML files, with the standard \<?php and ?\> as delimiters. The problem is, that YAML parsing takes precedence over PHP parsing, so “,” is interpreted as list item separator of YAML list.

How may I change the precedence? I tried something with LanguageInjectionPerformer but that did not work out yet.

---

<div class="post-metadata">

**Author:** ![yuriy.artamonov](https://sea1.discourse-cdn.com/flex001/user_avatar/platform.jetbrains.com/yuriy.artamonov/32/48_2.png) [@yuriy.artamonov](https://platform.jetbrains.com/u/yuriy.artamonov)\
**Post date:** [March 14, 2025, 6:12pm UTC](https://platform.jetbrains.com/t/how-to-change-precedence-when-injecting-language/929/2 "2025-03-14T18:12:01Z")

</div>

I think such tasks must be solved via `TemplateLanguageFileViewProvider` instead of language injection. Example in Handlebars plugin - `com.dmarcotte.handlebars.file.HbFileViewProvider`

See [GitHub - JetBrains/intellij-plugins: Open-source plugins included in the distribution of IntelliJ IDEA Ultimate and other IDEs based on the IntelliJ Platform](https://github.com/JetBrains/intellij-plugins/)

---

<div class="post-metadata">

**Author:** ![tarik.weiss](https://avatars.discourse-cdn.com/v4/letter/t/3ab097/32.png) [@tarik.weiss](https://platform.jetbrains.com/u/tarik.weiss)\
**Post date:** [March 17, 2025, 10:07am UTC](https://platform.jetbrains.com/t/how-to-change-precedence-when-injecting-language/929/3 "2025-03-17T10:07:10Z")

</div>

Okay, tried to register a TemplateFileViewProvider, changed the registration of the file ending (in the settings) and now have PHP code highlighted. But how do I tell the IDE, that the PHP\_TEMPLATE\_TEXT token contents are Yaml?
