Announcement Announcement Module
Collapse
No announcement yet.
Thyme: developing a new Spring MVC-compatible template engine Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Thyme: developing a new Spring MVC-compatible template engine

    Hi all,

    I'm currently finishing the development of the Thyme Template Engine [http://www.thymetemplates.org], a highly-extensible XML/XHTML template engine which will provide integration features for using it in Spring MVC applications.

    <marketing :-)>
    The main goal of Thyme is providing an elegant and well-formed way of creating templates, not requiring you to insert any code inside them and keeping in template logic to a minimum (if any). In order to achieve this, it is based on XML tags and attributes (although the Standard Dialect only uses attributes).
    </marketing :-)>

    For Spring MVC - Thyme integration, I created both ViewResolver and View implementations which should allow the user to configure thyme templates as usual Spring MVC views. To some extent I tried to imitate what has already been done for FreeMarker and Velocity, but it was quite a hard work... not because these two interfaces are difficult to understand, but because the hierarchy of abstract ViewResolvers and Views in Spring 3 is quite complex and it took me some time to decide where to "hook" my implementations (extending what classes and adding what features).

    My decision was to extend AbstractCachingViewResolver for my ViewResolver, but back-porting from UrlBasedViewResolver the "viewNames", "prefix" and "suffix" properties, as well as the ability to specify "redirect:" and "forward:" view names in controllers. I also implemented the Ordered interface so that this ViewResolver could be used in a chain.

    The matter is, although I know Spring MVC and have used it for some time, I am no real expert in the technology, so I would love to hear any opinions, suggestions or complaints about the way I integrated Thyme and Spring MVC from people that have tried something like this before or simply know better which would be the things you would ask from a Spring-compliant templating technology like this.

    For more info, the project's web site has tutorials both on Thyme general usage and Spring integration.

    Thanks,

    Daniel.

  • #2
    Hi

    Every template engine which is not servlet-based underneath (see JSP) is welcome - as I always say - if only Velocity had good Eclipse support, I would get rid of JSP entirely.

    First - good choice of OpenOffice to generate PDF
    Second - are you using OGNL (the question is based on one-minute look at your documents)? Haven't you considered using Spring Expression Language? It's pretty powerful - I've used it in my XML-RDBMS mapper and it's both powerful and fast.

    Keep up good work!

    regards
    Grzegorz Grzybek

    Comment


    • #3
      Hello Grzegorz, thanks for your answer.

      Originally posted by Grzegorz Grzybek View Post
      Second - are you using OGNL (the question is based on one-minute look at your documents)? Haven't you considered using Spring Expression Language? It's pretty powerful - I've used it in my XML-RDBMS mapper and it's both powerful and fast.
      Yes, Thyme uses OGNL for variable expression resolution. I think OGNL is a sort of almost-standard today in the world of java-related expression languages. It is powerful, very simple to learn, and is present nowadays in lots of technologies like Struts 2, Tapestry, iBATIS...

      I considered the Spring Expression Language as well, which is very nice, but using it would mean binding Thyme too much to Spring, which is not what I wanted. I want Thyme to be perfectly usable as a template engine on any application (be it Spring MVC, other type of webapp, or even standalone) while providing an integration package that will make it easily usable in Spring MVC apps. In this scenario, a more neutral language like OGNL fitted better.

      Regards,
      Daniel.

      Comment


      • #4
        Hi again,

        After thinking a little bit more about it, I think I could obtain some advantages from creating a Spring-specific dialect for Thyme that uses Spring EL instead of OGNL. That should improve interoperability, especially with form input "path" attributes.

        This would mean the Standard Thyme dialect would still use OGNL, but the optional thyme-spring3 package would include a Spring-Thyme dialect using SpEL, so that you can use SpEL in your Spring MVC apps while Thyme's core stays free from Spring ties.

        I still have to figure out how to do that correctly and even if it would be possible at all, but anyway thanks for making me think ;-)

        Regards,
        Daniel.

        Comment


        • #5
          Daniel,

          You may want to look at how Web Flow allows the EL to be pluggable (they support OGNL, Unified EL, and SpEL). Sounds like something similar might be useful in your case.

          Hope this helps
          - Don

          Comment


          • #6
            @dfernandez

            Also one more suggestion - it would be helpful if you compare your engine with Velocity/FreeMarker.

            (I've bookmarked your site anyway )

            regards
            Grzegorz Grzybek

            Comment

            Working...
            X