Display-name-expression with conditional


#1

Enonic version: 7.2.0
OS: Ubuntu 18.04

I thought the display-name-expression was supporting ES6 template literals, but I tried the following expression (which is valid and is working on other ES6 plataforms, like web browsers):
${shortTitle ? shortTitle : title}
It is not working at all, leaving an empty displayName

You can test it on you web browser console:
let shortTitle = ''; let title = 'thisIsTitle'; `${shortTitle ? shortTitle : title}`
the output will be: "thisIsTitle"

– EDIT –
@SOLVED
After many tests and debugging of enonic frontend source code, I found that this expression works for my needs:
${``${shortTitle}` ? `${shortTitle}` : `${title}`}


#2

It is not as clever as that, no. And it was never intended to be. You can combine multiple form fields with occasional static text inside the expression, but that’s as far as it goes.


#3