Bristle template: when you don’t have time to do your Moustache
Usually I generate my pages with Velocity. Recently I had a project where even implementing Velocity was not worth the time. I tried both MessageFormatter and StringTemplates and both had problems with some portion of HTML/Javascript markup.
So I did what we, engineers always do in this situation: run your own. Good news, it took just over an hour and I ended with a single very small file. It can only variable substitution but that was enough for me. Here it is:
The best part: it has no dependencies so you can just copy file into your project and template away.
Of course you can Maven just as well:
<repositories> ... <repository> <id>codebistro-open</id> <name>codebistro-open repo</name> <layout>default</layout> <url>http://codebistro.googlecode.com/svn/repo/</url> </repository> ... </repositories> ... <dependencies> ... <dependency> <groupId>org.codebistro.util</groupId> <artifactId>misc</artifactId> <version>1.0-SNAPSHOT</version> </dependency> <dependencies>
Microframeworks are popular these days. This thing doesn’t even qualify to be called micro- or even nano- but I got a feeling I am going to use Bristle template in the future…
Yegor 12:04 pm on 2011-01-16 Permalink |
There is another possible alternative: http://mojo.codehaus.org/buildnumber-maven-plugin/ (for Maven only).
sashaov 12:45 pm on 2011-01-16 Permalink |
Yeah, I remember looking at it then. I needed the build number to use it right in the program code and it was a bit of challenge to get it out of that mojo, so I had wrote my own
.This Mojo creates a property file which is then available to the program.