Dynamically Populate Image Source in HTML

36 views
Skip to first unread message

Rodrigo Pereira da Silva

unread,
Oct 16, 2016, 8:11:48 AM10/16/16
to Play Framework
Hi Guys,

   I haven't found any way to populate a image source dynamically in Play. I am using the following code:

<li><a class="" href=""><img src="@routes.Assets.versioned("images/@orderItem.getOriginNameId().png")" alt="" /></a></li>

However, Twirl does not resolve the @orderItem.getOriginNamedId(). Any idea how it is possible to do that in play?


Thank you,

Rodrigo Silva

Thibault Meyer

unread,
Oct 16, 2016, 12:53:02 PM10/16/16
to Play Framework
try

<li>
 
<a class="" href="">
 
  <img src="@routes.Assets.versioned("images/" + orderItem.getOriginNameId() + ".png")" alt="" />
 
</a>
</li>

Rodrigo Pereira da Silva

unread,
Oct 16, 2016, 3:31:37 PM10/16/16
to Play Framework
It worked fine. Thank you. So, I suppose that once a @ is found, Twirl interprets as variables everything that it is not between quotation marks. 
Reply all
Reply to author
Forward
0 new messages