0

I need to append a suffix to an URL in Velocity (inside a Liferay template).

I have the following (simplified) code:

#set($isMobile = "")
<img src="http://www.example.com/icon-facebook$isMobile.png" >

#set($isMobile = "-mobile")
<img src="http://www.example.com/icon-facebook$isMobile.png" >

In my intention this should result in:

<img src="http://www.example.com/icon-facebook.png" >
<img src="http://www.example.com/icon-facebook-mobile.png" >

but instead I'm obtaining this (as variable is printed literally and not parsed)

<img src="http://www.example.com/icon-facebook$isMobile.png" >

Please, how to solve?

Luca Detomi
  • 5,564
  • 7
  • 52
  • 77

1 Answers1

2

the right sintax for Velocity is

<img src="http://www.example.com/icon-facebook${isMobile}.png" >

Daniele Baggio
  • 2,157
  • 1
  • 14
  • 21