简体   繁体   中英

How to pass variable to asset function in twig, Symfony 2

How to pass variable to asset function in twig, Symfony 2 ?

The images are in directory:

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

Trying to upload images to webpage gives error:

Unexpected token "punctuation" of value ")" .

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

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

解决的办法是追加'':

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM