olga
olga

Reputation: 969

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') }}" />  #}

Upvotes: 1

Views: 2291

Answers (1)

olga
olga

Reputation: 969

The solution is to append '' :

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

Upvotes: 2

Related Questions