More Groovy Goodness


More Groovy Goodness

I submitted a new feature today, using classic technology from bash/perl/php/etc I bring you an easier way to build templates in Groovy.

Plenty of languages have them, so I just had to put it in. GroovyServlets are now even easier to write. Here is an example that I am running on my website right now:

import java.util.Date

if (session.counter == null) {
 session.counter = 1
}

out.println(<<<EOS
<html>
<head>
<title>Groovy Servlet</title>
</head>
<body>
Hello, ${request.remoteHost}: ${session.counter}! ${new Date()} 
<br>src
</body>
</html>
EOS)

session.counter = session.counter + 1

So now the pages can look a little more JSP-EL like. As you can see, I’ve exposed the session in the script context and am using the set/getAttribute as the generic setters and getters for the class. This has gotten me thinking about being able to just import the textual part of the page or to have a pair of pages so the template text is in one place and the implementation is in another. For now, this is good enough.

I’ve also gotten rid of my share of bugs since I started submitting code. Maybe you should go and play with it see if you can file some more? There are still some core things left that need to be implemented, I’m looking at some of them now to see what I should work on next. I think the number one thing on my list is regex support.