hi there! can you mention template engine that you...
# random
m
hi there! can you mention template engine that you`re using in your kotlin project? (pros\cons would be a plus 😃 )
j
kotlinx.html Nice way of working with a DSL. And easy to create custom functions for elements.
âž• 2
e
Didn't use yet, but looks promising: https://github.com/casid/jte Latest release includes Kotlin support
m
@Jurriaan Mous not sure that this one is good option for me - i’m going to create string values as result @edrd with same thoughts I’ve added https://korlibs.soywiz.com/korte/ recently tnx for reply!
🤘 1
m
I’ve used Freemarker for a while. Really cumbersome. Can’t recommend. Migrated everything to
kotlinx-html
for the moment. PDF and email generation.
m
@Marc Knaup still my goal is get plain string(after few additional
if
and
when
, maybe with some formatting) =) I’ve started previewing thymeleaf with their text mode and the thing that force me to try korte was this include trick
Copy code
key1 to [(\${#numbers.formatDecimal(bigdecimalBlaBLaVar,1,2)})][(\${blaBlaVar})]",
key2 to +[(\${#numbers.formatDecimal(bigdecimalBlaBLaVar,1,2)})][(\${blablablah})] **[#th:block th:replace=\"key1\"][/th:block]** "
it was really tricky to find it, and also looks like thymeleaf is an overhead for my case btw - this how it looks with kotre
Copy code
+{{ formatAmount(blabla) }}{{ blablablah }}{% include \"key1\" %}
m
I'd recommend not to use something that brings it's own language. That way you lose all the type safety, auto completion and functionality of Kotlin that you can use in a Kotlin DSL-based template solution.
m
Sincerely, I just used Kotlin’s multi-line string interpolation and it worked well for my needs without importing a templating library.