Reusing variables from the same th:with

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Reusing variables from the same th:with

RodionGork
Daniel, hi once again!

I also wanted to ask you to improve expression executor so that variables defined inside th:with attribute could be used later inside the same attribute. For example:

th:with="company=${someMap[someIndex].customer},account=${cities[company.place].register.find(company)}"

Here company is defined at first and then it is used for define next variable.

Currently we have clumsy workaround for this - put extra DIV or SPAN around current tag with th:remove="tag" and define first variable in it. Surely it slightly violates the principle of "templates are prototypes" since they have unnecessary tag.
Reply | Threaded
Open this post in threaded view
|

Re: Reusing variables from the same th:with

danielfernandez
Administrator
Hi,

That could be an interesting enhancement. Would you be so kind to add it to https://github.com/thymeleaf/thymeleaf/issues ?

Thanks,
Daniel.

Reply | Threaded
Open this post in threaded view
|

Re: Reusing variables from the same th:with

danielfernandez
Administrator
For the record, an enhancement ticket has been created here: https://github.com/thymeleaf/thymeleaf/issues/98