Open mnonnenmacher opened 4 months ago
It would be awesome of this allows us to get rid of the overly complex FreemarkerTemplateProcessor which basically just makes the Kotlin models more accessible from Freemarker.
make it easier to call Kotlin code from the templates without having to learn another syntax.
But isn't it so that e.g. control structures still require JTE syntax, like @for
etc.? Because of that, just to document the idea, I was wondering whether we could instead simply create a Kotlin script reporter that returns a (huge) string which gets expanded / interpolated by standard Kotlin functionality.
But isn't it so that e.g. control structures still requite JTE syntax, like
@for
etc.?
Yes.
Because of that, just do document the idea, I was wondering whether we could instead simply create a Kotlin script reporter that returns a (huge) string which gets expanded / interpolated by standard Kotlin functionality.
This is definitely also an option. It's somehow the opposite approach to template engines. With template engines you write the template in the native output format like Markdown and inject some code here and there, so the "main" syntax of the template file is that of the output format. With the Kotlin script approach the code part becomes easier, but it becomes harder to ensure that the syntax of the output format is followed (expect when a DSL for the format is available).
With the Kotlin script approach the code part becomes easier, but it becomes harder to ensure that the syntax of the output format is followed (expect when a DSL for the format is available).
True. Maybe IntelliJ language injections could help here.
Add a JTE template reporter as an alternative to the Freemarker template reporter. In constrast to Freemarker, JTE supports Kotlin expressions in templates which would make it easier to call Kotlin code from the templates without having to learn another syntax.