spring-integration icon indicating copy to clipboard operation
spring-integration copied to clipboard

Add templating support to ObjectToStringTransformer [INT-1036]

Open spring-operator opened this issue 15 years ago • 7 comments

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:

<object-to-string-transformer input-channel="newAppointmentsChannel" template="classpath:templates/new-appointment-email.st" output-channel="doctorEmailChannel" />	

Code attached using foundational bits in SPR-6987.


Affects: 2.0 M2

Attachments:

Issue Links:

  • SPR-6987 String Template support ("depends on")
  • #7771 Consider Adding a Freemarker Transformer

spring-operator avatar Mar 15 '10 11:03 spring-operator

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 avatar May 05 '10 02:05 spring-operator

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 avatar Nov 02 '10 13:11 spring-operator

Keith Donald commented

I really think we should get Andy to do our own Spel-based StringTemplate and then just support that.

spring-operator avatar Nov 02 '10 14:11 spring-operator

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 avatar Nov 02 '10 15:11 spring-operator

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 avatar Nov 02 '10 17:11 spring-operator

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 avatar Jun 26 '12 19:06 spring-operator

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.

spring-operator avatar Sep 01 '15 20:09 spring-operator