extend language

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

extend language

blr
Hi,

Is it comlex to extend the Thymeleaf language ?
for example to add many methods on #strings
Thanks,

Blr
Reply | Threaded
Open this post in threaded view
|

Re: extend language

danielfernandez
Administrator
Hi,

It is not complex to extend Thymeleaf by creating your own dialects, and these dialects can include your own attribute/tag processors.

Nevertheless, adding methods to #strings is a different thing. The "#strings" object is a specific utility object added by the Standard Dialects for expression evaluations in OGNL and/or Spring EL. Adding methods to it would mean to:

  1. Either modify the Strings class itself (which is the one to which the #strings utility object belongs).
  2. Or create your own dialect based on the Standard ones, adding a similar mechanism for expression evaluation but with a different #strings object (created by you).

Nevertheless, maybe you're going too far: if all you need is more/specific features for dealing with Strings, all you need to do is create an object containing all the methods you need and then just adding it to the context (IContext object if you are not using Spring, or the ModelAttributes if you are). And then you will be able to use this object's methods just like any others.

Regards,
Daniel.