Skip to content

Add templating support to ObjectToStringTransformer [INT-1036] #5031

Open

Description

@spring-operator

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:

Activity

  1. spring-operator commented on May 5, 2010

    @spring-operator
    ContributorAuthor

    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).

  2. spring-operator commented on Nov 2, 2010

    @spring-operator
    ContributorAuthor

    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?

  3. spring-operator commented on Nov 2, 2010

    @spring-operator
    ContributorAuthor

    Keith Donald commented

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

  4. spring-operator commented on Nov 2, 2010

    @spring-operator
    ContributorAuthor

    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?

  5. spring-operator commented on Nov 2, 2010

    @spring-operator
    ContributorAuthor

    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.

  6. spring-operator commented on Jun 26, 2012

    @spring-operator
    ContributorAuthor

    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

  7. spring-operator commented on Sep 1, 2015

    @spring-operator
    ContributorAuthor

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions