What is the __ doing in this snipped? "*{roles[__${roleStat.index}__]}"

Viewed 133

In thymeleaf,

What is the [__${roleStat.index}__] part doing?

I understand that this is the array index, but what are the __ for?

1 Answers

This doc says (on page 26):

Preprocessed expressions are exactly like normal ones, but appear surrounded by a double underscore symbol (like __${expression}__ ).

So it's for preprocessing an expression before it's further used in whatever it's surrounded by.

EDIT: Let's additionally clarify what this does in your scenario (if it wasn't clear, yet). It's processing ${roleStat.index} to get a literal index number, to then use it as the arrays index.

Related