Supported expression syntax
A list of the expression syntaxes currently supported in the latest version of ThymeleafJS. The full list of expression syntaxes was taken from the Thymeleaf docs here: https://www.thymeleaf.org/doc/tutorials/3.0/usingthymeleaf.html#standard-expression-syntax
Simple expressions
- [x] Variable Expressions:
${...} - [ ] Selection Variable Expressions:
*{...} - [x] Message Expressions:
#{...} - [x] Link URL Expressions:
@{...} - [x] Fragment Expressions:
~{...}
Complex expressions
- [x] Iteration expressions
Literals
- [x] Text literals:
'one text','Another one!',... - [x] Number literals:
0,34,3.0,12.3,... - [x] Boolean literals:
true,false - [ ] Null literal:
null - [x] Literal tokens:
one,sometext,main,...
Text operations
- [x] String concatenation:
+ - [x] Literal substitutions:
|The name is ${name}|
Arithmetic operations
- [ ] Binary operators:
+,-,*,/,% - [ ] Minus sign (unary operator):
-
Boolean operations
- [x] Binary operators:
- [x]
&& - [x]
and - [x]
|| - [x]
or
- [x]
- [ ] Boolean negation (unary operator):
- [x]
! - [ ]
not
- [x]
Comparisons and equality
- [ ] Comparators:
- [ ]
> - [ ]
< - [ ]
>= - [ ]
<= - [ ]
gt - [ ]
lt - [ ]
ge - [ ]
le
- [ ]
- [x] Equality operators:
- [x]
==,=== - [x]
!=,!== - [x]
eq - [x]
ne
- [x]
Conditional operators
- [x] If-then:
(if) ? (then) - [x] If-then-else:
(if) ? (then) : (else) - [ ] Default:
(value) ?: (defaultvalue)
Special tokens
- [ ] No-Operation:
_
The message expression is one that would be really handy. I will have a look on how we can implement it
How would we do a .substring now?
I think you can do a .substring on any string now as both Java and JavaScript both call that method "substring". I haven't tried it with that method in particular, but being able to do method calls on objects is already possible.
alright!
Hi, I have a problem
let templateEngine = new TemplateEngine({
...STANDARD_CONFIGURATION,
messageResolver: async (key, parameters) => resolveMessage(key, lang, 'defaultMessage')
})
const context = { user: user } templateEngine.processFile(fileName, context)
, it work on tags loike this with #
, but not on variable expressions
<p th:text="#{email.activation.greeting(${user.firstName})}">
Dear
</p>
, this results in - Dear{0}
The templates I have worked fine with spring thymeleaf
Did I forget something ?