Concat in Ternary Condition | Community
Skip to main content
maynors2427659
Level 2
February 1, 2019
Solved

Concat in Ternary Condition

  • February 1, 2019
  • 3 replies
  • 2882 views

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

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Gaurav-Behl

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 */-->

3 replies

smacdonald2008
Level 10
February 1, 2019

See the HTL Spec - it gives an example -- htl-spec/SPECIFICATION.md at master · adobe/htl-spec · GitHub

Gaurav-Behl
Gaurav-BehlAccepted solution
Level 10
February 1, 2019

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 */-->
maynors2427659
Level 2
February 2, 2019

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=''}