You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It could be useful to add a "default attribute processor" that simply matches any name (with the lowest precedence, so that it acts as a default) and outputs an attribute with the same matched name, with value equal to the evaluated expression.
Not all, but many of them. For example, th:selected works differently, because it evaluates its expression as boolean and outputs selected="selected" if true, and does not output at all if false.
Also, some attributes are actually required, so when evaluating to a null expression they must not dissapear from the tag, but simply output the empty string, like <form action="">. These would not be replaced either.
Activity
ultraq commentedon Jun 23, 2014
Could this be a replacement for all the HTML attribute processors we have? (
th:class,th:href,th:selected...)danielfernandez commentedon Jun 23, 2014
Not all, but many of them. For example,
th:selectedworks differently, because it evaluates its expression as boolean and outputsselected="selected"if true, and does not output at all if false.Also, some attributes are actually required, so when evaluating to a null expression they must not dissapear from the tag, but simply output the empty string, like
<form action="">. These would not be replaced either.Antibrumm commentedon Jun 24, 2014
What if you simply manage a list of attributes that allow null to empty string conversion?
Also: Probably the same approach could be possible for append and prepend processors?
danielfernandez commentedon Sep 27, 2015
Default attribute support has been implemented in Thymeleaf 3.0, for the Standard Dialects.
Already in
3.0.0-SNAPSHOT