This post originated from an RSS feed registered with Java Buzz
by Warner Onstine.
Original Post: Thinking about DSLs for Tapestry 5
Feed Title: Tapestry Live
Feed URL: http://www.jroller.com/WarnerOnstine/feed/entries/rss
Feed Description: Home of the Tapestry Live book by Warner Onstine.
I have been thinking about these two for a while and a couple of weekends I wanted to touch base with Howard on them to get a feel for how much work would be involved in hooking them into Tapestry 5.
Routing DSL
When I first saw Rails routes I really liked the way it handled things and wanted to do something similar for Tapestry. A friend of mine mentioned someother routing systems for python that I will take a look at. So, this first DSL would be all Groovy, what would be involved in getting this into Tapestry 5?
Also, I will need to dig into Tapestry‘s new IoC container which is very naming-convention driven for automatically picking up services. Instead of having to create a HiveMind descriptor file (as we did in Tapestry 4) we just need to follow a standard naming-convention for our services to make sure that Tapestry will pick it up. I really like this, but I‘m sure others won‘t be so thrilled (how does Tapestry know how to magically get my stuff, the magic comment was really applied towards the Abstract-classes in Tapestry 4, which are now gone, gone, gone).
I think that this will help Tapestry 5 reach out to everyone who wants the REST-style URLs which are nice, clean and understandable. And of course the new routing could take into account what kind of content you want (HTML, XML, whatever) and direct you to the right pages.
A new View DSL
Yes, I am talking about a new templating system, but not using one of the existing ones as I don‘t know how you would really integrate those into Tapestry. What I‘m talking about is something like Haml which is essentially Yaml for HTML. There is alot to like about Haml. First, it uses convention (like tabs) to denote HTML nesting, there is no need for writing begin and end HTML tags. Second, it‘s an extremely simple syntax to learn and I don‘t think any HTML designer would complain about fewer angle-brackets (they might complain about not being able to use Dreamweaver).
This DSL though would be a bit more difficult to implement (at least according to Howard, and I have no reason to doubt him). Here are a few of the ways he suggested I could do it:
Could generate the template tokens just like the XML does
Would need to override the TemplateParser to achieve this
Might be able to do it somehow through the PageLoader, but Tapestry 5 isn‘t really setup for this (yet, could be an internal change that won‘t affect outside apps)
Could also inject into the TemplateParserImpl as a new service that would actually delegate to the old service when you didn‘t need to use it
This last approach will definitely be the one I take as I embark on creating this new DSL. I‘m going to flesh out the grammar for both of these first as I start playing around with these so expect to see some updates on it.
Also, I thought I would post some of the things that I find in the Tapestry 5 internals and thought I‘d setup a new section on this blog just for that. If you have any specific things that you‘d like me to look at while I‘m digging around please post it in the comments.