thymeleafjs icon indicating copy to clipboard operation
thymeleafjs copied to clipboard

Supported expression syntax

Open ultraq opened this issue 8 years ago • 5 comments

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
  • [ ] Boolean negation (unary operator):
    • [x] !
    • [ ] not

Comparisons and equality

  • [ ] Comparators:
    • [ ] >
    • [ ] <
    • [ ] >=
    • [ ] <=
    • [ ] gt
    • [ ] lt
    • [ ] ge
    • [ ] le
  • [x] Equality operators:
    • [x] ==, ===
    • [x] !=, !==
    • [x] eq
    • [x] ne

Conditional operators

  • [x] If-then: (if) ? (then)
  • [x] If-then-else: (if) ? (then) : (else)
  • [ ] Default: (value) ?: (defaultvalue)

Special tokens

  • [ ] No-Operation: _

ultraq avatar Apr 20 '18 09:04 ultraq

The message expression is one that would be really handy. I will have a look on how we can implement it

rob-bar avatar Mar 28 '19 13:03 rob-bar

How would we do a .substring now?

rob-bar avatar Mar 28 '19 13:03 rob-bar

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.

ultraq avatar Mar 28 '19 22:03 ultraq

alright!

rob-bar avatar Apr 03 '19 08:04 rob-bar

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 ?

oaj avatar Mar 16 '23 22:03 oaj