You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add templating support to ObjectToStringTransformer [INT-1036] #5031
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.
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).
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?
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?
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.
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!
Activity
spring-operator commentedon May 5, 2010
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).
spring-operator commentedon Nov 2, 2010
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?
spring-operator commentedon Nov 2, 2010
Keith Donald commented
I really think we should get Andy to do our own Spel-based StringTemplate and then just support that.
spring-operator commentedon Nov 2, 2010
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?
spring-operator commentedon Nov 2, 2010
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.
spring-operator commentedon Jun 26, 2012
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
spring-operator commentedon Sep 1, 2015
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.