@yield and @section issue. PhpStorm 2020.3 blade templating.

In my layout file, in `head` tag I `yield("css")`.

in another file, I extend the layout file and `@section("css")`, but inside the section if I put my ` <link rel="stylesheet" href="{{ asset("css/my.css") }}" />`. PhpStorm shows the line as problem.

problems:

```

Unexpected token

Selector matches unknown element rel

Selector matches unknown element href

```

However, it works in the browser.

What am I doing wrongly? Thank you.

0

Hi there,

Do not use "css" and "javascript" as section names for such purposes. PhpStorm injects actual CSS / JavaScript language into such blocks... and

<link rel="stylesheet" href="{{ asset("css/my.css") }}" />

is a HTML and not CSS.

Those are the most commonly used names in many projects when using blocks/sections with actual CSS and JavaScript (be it Blade, Twig or Smarty template) and it is done as a result of a popular user request.

Solution: use another/more appropriate section names instead, like "styles" (instead of "css") and "scripts" (instead of "javascript").

 

Alternatively, if you do not care about that at all (e.g. "I want to use whatever name I want" / "It's not my project / I cannot change that" or any other reason) then just to go "Settings/Preferences | Editor | Language Injections" and disable these 2 rules:

1

请先登录再写评论。