Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/symfony/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/227.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Symfony 2.7中的全局细枝参数变换_Symfony_Twig - Fatal编程技术网

Symfony 2.7中的全局细枝参数变换

Symfony 2.7中的全局细枝参数变换,symfony,twig,Symfony,Twig,我在config.yml中添加了一些配置参数,如: twig: globals: brands: 'land-rover': 'Land Rover' 我的问题是,一旦我使用了这根内部树枝,路虎就变成了路虎 {% for slugKey, name in brands %} <li><a href="{{ path('getSearchResultsByBrand', {'slug': slugKey, 'edition': edition.e

我在config.yml中添加了一些配置参数,如:

twig:
  globals:
    brands:
      'land-rover': 'Land Rover'
我的问题是,一旦我使用了这根内部树枝,路虎就变成了路虎

{% for slugKey, name in brands %}
    <li><a href="{{ path('getSearchResultsByBrand', {'slug': slugKey, 'edition': edition.edition}) }}">{{ name }}</a></li>
{% endfor %}
{%用于slugKey,品牌名称%}
  • {%endfor%}

    为什么这种转换会自动发生?我如何防止它?

    检查此问题:此修复:谢谢duncan。因为我只需要对一个变量数组使用它,所以我在twig中做了一个| replace。@duncan你应该把它作为aswerCheck发布这个问题:这个修复:谢谢duncan。因为我只需要一个变量数组,所以我在twig中做了一个| replace。@duncan你应该把它作为一个aswer发布