如何在twig中将变量传递给资产函数,Symfony 2

时间:2015-12-26 17:34:41

标签: image symfony twig src assetic

如何在twig中将变量传递给资产函数,Symfony 2?

图片在目录中:

C:\Bitnami\wampstack-5.5.30-0\sym_prog\proj3_27\web\bundles\meeting\images\uploads

尝试将图片上传到网页会出错:

  

意外的令牌"标点符号"价值")"

<img src="{{ asset( 'bundles/meeting/images/uploads/'~entity.path~ ) }}" />  {# does not work #} 

 {# working <img src="{{ asset('bundles/meeting/images/uploads/8211c4c586eb4460d3ed08edcc46972bb72dcbe0.png') }}" />  #}

1 个答案:

答案 0 :(得分:0)

解决方案是追加&#39;&#39; :

<img src="{{ asset( 'bundles/meeting/images/uploads/'~entity.path~'' ) }}" />