A simplified API for working with Thymeleaf expressions.
Minimum of Java 8 and Thymeleaf 3.1 required.
Add a dependency to your project with the following co-ordinates:
- GroupId:
nz.net.ultraq.thymeleaf
- ArtifactId:
thymeleaf-expression-processor
- Version:
3.2.0
Check the project releases for a list of available versions. Each release page also includes a downloadable JAR if you want to manually add it to your project classpath.
Create an instance of ExpressionProcessor
using the current expression context
(the context object passed to Thymeleaf processors is a type of IExpressionContext
),
and then parse/process any string that is a Thymeleaf expression, using any of
the instance methods described below:
Parses an expression, returning the matching expression type.
Parses an expression under the assumption it is a fragment expression. This method will wrap fragment expressions written in Thymeleaf 2 syntax as a backwards compatibility measure for those migrating their web apps to Thymeleaf 3. (This is because Thymeleaf 3 currently does the same, but expect this method to go away when Thymeleaf starts enforcing the new fragment expression syntax itself.)
Parse and executes an expression, returning whatever the type of the expression result is.
Parse and execute an expression, returning the result as a string. Useful for expressions that expect a simple result.