Open spring-operator opened 14 years ago
Dave Syer commented
Maybe we could use a filename suffix convention to determine the template type (String Template, Freemarker, Velocity)? Or plug in a template engine strategy? AFAIR the template support in Spring is not web specific so it should be possible to plug into that (with immediate support in existing releases of Spring and String Template support once SPR-6987 is resolved).
Mark Fisher commented
I think the template strategy is the way to go. This would be analogous to the Serializer strategy for the payload-serializing-transformer. Like that transformer, this one would rely on basic Java (toString) for the default, but allow the configuration of the strategy. We should probably support StringTemplate, Freemarker, and Velocity. Any others?
Keith Donald commented
I really think we should get Andy to do our own Spel-based StringTemplate and then just support that.
Mark Fisher commented
Relying on SpEL alone would be ideal. However, I'm also considering cases where someone needs to reference a template for a significant piece of text (e.g. an email message body). Furthermore, they might have existing Velocity or Freemarker templates for that. Do you think we would even want to support all of that via strategies within SpEL?
Keith Donald commented
SpEL templating similiar to StringTemplate should cover email templating requirements with no problem. If someone wanted to reuse their existing templates, I'd say they'd just plugin Freemarker or Velocity then.
Gunnar Hillert commented
With #5031 on my plate for one of the upcoming Sprints, I was wondering how sophisticated we may want to go with the Templating support. Would SpEL templating be sufficient or should we add support for other templating mechanisms such as Scalate [2], Freemarker[3] or Velocity [4]?
Scalate might be interesting as well, as it would introduce Scala-based templating. This might be something that also feeds into creating Scala-based adapters.
If you spin the thought-process further, there might also be use-cases for providing foundational support for document transformers. As I am in the process of creating a Print component [5], I am wondering if down the road, we may consider document transformers e.g. for Pdf, Excel, Word etc. This could be modeled based (borrowed from) on the respective Spring MVC support classes [6] [7].
Wanted to start the discussion to determine the scope of the Jira and or additional Jiras to be created. Any thoughts are extremely welcome!
[1] https://jira.springsource.org/browse/INT-1036 [2] http://scalate.fusesource.org/ [3] http://freemarker.sourceforge.net/ [4] http://velocity.apache.org/ [5] https://jira.springsource.org/browse/INTEXT-1 [6] http://static.springsource.org/spring/docs/3.1.x/spring-framework-reference/html/view.html#view-document-configsubclasspdf [7] http://static.springsource.org/spring/docs/3.1.x/spring-framework-reference/html/view.html#view-document-configsubclasses
Gary Russell commented
I just whipped up a Freemarker transformer for a question on StackOverflow.
I wasn't aware of this issue, so I opened #7771.
Keith Donald opened INT-1036 and commented
As a user I'd like the ability to reference a template to use to generate the transformed String, where the model for the template would be the payload.
Example usage:
Code attached using foundational bits in SPR-6987.
Affects: 2.0 M2
Attachments:
Issue Links:
7771 Consider Adding a Freemarker Transformer