How to create a custom, complex render condition using HTL and Java Sling Models instead of JSPs for AEM TouchUI
What is a Granite render condition?
“Render condition” is a fairly self-explanatory term. More specifically, according to Granite documentation, it is “a mechanic to indicate if the component should be rendered or not”.
So how does it work? You can find an example that you’ll probably recognize if you’ve ever used Assets (although there are hundreds of others): you cannot perform the same actions on an original asset as on a live copy.
The use case
Note: This use case was inspired by this question on the AEM Experience League forums. Thanks user neos45149736 for an interesting challenge
Here is what we want to do: create a component edit dialog which will render a certain field only if the component is on a page with a certain Navigation Title.
Note: for this tutorial I am using Editable templates.
I won’t go over how to create a template, I’ll assume you already have one.