Expand my Community achievements bar.

July 31st AEM Gems Webinar: Elevate your AEM development to master the integration of private GitHub repositories within AEM Cloud Manager.

Ternary Sightly Condition is not working


Level 3

Hi Team,

              I have to display the current page title on the basis of checkbox value and in else condition i need to display deafult vale.

I tried  but it is not working it is act as string 

title:${properties.pagetitle ?'currentPage.title':' properties.headline'}

it display me currentPage.title


is there anything wrong in the syntax.

5 Replies


Employee Advisor

Hi @savi50 ,

Yes there is syntax error (Do not use inverted commas inside {}), please use as : 

${properties.pageTitle? currentPage.title : properties.headline}



Level 3

Hi @milind_bachani ,

                      I already tried above but it is giving error 

${properties.pagetitle ?currentPage.title:properties.headline}: mismatched input '}' expecting {'.', 'in', '&&', '||', '[', ':'}


Level 1

Please separate ternary operators with a white-space to provide clarity to the parser. In your case this would be where the colon `:` is used:


${properties.pageTitle ? currentPage.title : properties.headline}

You may also want to confirm your letter-casing and scope (component vs page).


Employee Advisor

Please use proper spacing before and after the operators ( ? : )and then try. 
I also reverified the same on my local it works fine when I use something like :

${properties.prop1 ? properties.prop1 : currentPage.pageTitle}
${properties.prop1?properties.prop1 : currentPage.pageTitle}

But, gives a blank page when I do 

${properties.prop1 ? properties.prop1:currentPage.pageTitle}

Hence, please check the whitespaces.