简体   繁体   English

在 laravel 中使用刀片语法时,语法错误,意外标识符“后端”,期望“)”

[英]syntax error, unexpected identifier "backend", expecting ")"when using blade syntax in laravel

I am trying to use the ternary operator using blade to print out the active class for an <li> tag by checking the name of the current route using the code below我正在尝试使用三元运算符使用刀片打印出<li>标记的活动类,方法是使用下面的代码检查当前路线的名称

<li class="nav-item {{ Route::currentRouteName() == 'backend.categories' ? 'active' : '' }}">

However, this doesn't work and i am presented with a ParseError which says但是,这不起作用,我收到一个 ParseError ,上面写着

syntax error, unexpected identifier "backend", expecting ")"

We don't have enough information to understand what's going on.我们没有足够的信息来了解发生了什么。

From what I can see, the error is not on the line that you copied.据我所知,错误不在您复制的行上。 Maybe try to search in the controller or in the routes file to see if there is some syntax error.也许尝试在控制器或路由文件中搜索以查看是否存在语法错误。

Tip: you can use Blade conditional classes to have a cleaner view.提示:您可以使用Blade 条件类来获得更清晰的视图。

而是使用$request->route()->getName() ...并考虑 Laravel 版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Laravel Blade:解析错误:语法错误,意外的&#39;:&#39;,期望&#39;(&#39; - Laravel Blade: Parse error: syntax error, unexpected ':', expecting '(' 刀片模板语法错误,意外的&#39;}&#39;-laravel 5 - error in blade template syntax error, unexpected '}' - laravel 5 laravel blade包含错误 - 语法错误,意外 - laravel blade include error - syntax error, unexpected Laravel:获取刀片组件语法错误,意外的“endif”(T_ENDIF),预期文件结束 - Laravel: getting blade components syntax error, unexpected 'endif' (T_ENDIF), expecting end of file FatalErrorException:语法错误,意外&#39;:&#39;,期待&#39;,&#39;或&#39;;&#39; 在Laravel - FatalErrorException : syntax error, unexpected ':', expecting ',' or ';' in Laravel 语法错误,意外的&#39;[&#39;,期望&#39;)&#39; - Syntax error, unexpected '[', expecting ')' 语法错误,意外&#39;。&#39;,期待&#39;)&#39; - syntax error, unexpected '.', expecting ')' Symfony2 Doctrine:语法错误,意外&#39;功能&#39;,期待&#39;标识符&#39; - Symfony2 Doctrine: syntax error, unexpected 'function', expecting 'identifier' 语法错误,意外标识符枚举 laravel - syntax error, unexpected identifier enum laravel Opencart中的语法错误期望标识符 - Syntax error expecting identifier in Opencart
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM