Expand my Community achievements bar.

SOLVED

Concat in Ternary Condition

Avatar

Level 2

Hi,

   Is there a way to concat a var or a string in a ternary condition as shown below:

<sly>"${ properties.timezoneminute ? ":"  ${properties.timezoneminute} : ":00"</sly>

Off course, this does not work. In the example, I want to show the timezone minutes if there is any chosen otherwise show just 00. EST+18:15, EST+19:00, etc... The "var" I am trying to concat is the Colon (":").

Thanks

1 Accepted Solution

Avatar

Correct answer by
Level 10

Try this -

${properties.timezoneminute ? ${properties.timezoneminute} : [ ${properties.timezoneminute}, '00'] @ join=':'}

This is what you would want to use --

1.2.4. Array Join

The join option allows to control the output of an array object by specifying the separator string.

${['one', 'two'] @ join='; '} <!--/* outputs: one; two */-->

View solution in original post

3 Replies

Avatar

Correct answer by
Level 10

Try this -

${properties.timezoneminute ? ${properties.timezoneminute} : [ ${properties.timezoneminute}, '00'] @ join=':'}

This is what you would want to use --

1.2.4. Array Join

The join option allows to control the output of an array object by specifying the separator string.

${['one', 'two'] @ join='; '} <!--/* outputs: one; two */-->

Avatar

Level 2

Thank you so much, that's the answer I needed. Just made a few changes in case someone is interested

${!properties.timezoneminute ? ":00" : [':', properties.timezoneminute] @ join=''}