During the process of writing my first Grails application, Groovyquiz.com (coming soon), I needed a clean way to write the quiz text, and was generally not interested in writing everything as HTML.
I have always liked Textile, and quickly found a couple of options for using that format via two Java libraries: JTextile and textile4j. Now, I don’t know about you, but when I need a Java library of any nature, I tend to go with one that has most and preferably all of the following:
- Jar file
- JavaDocs
- Example code
- README file
- Tests
When I don’t see those, I generally disregard the project and try to find something else. That was the case with JTextile… the download included 3 files: one java source file (JTextile.java), one text file for testing, and another java source file for running the test (Test.java). Where as textile4j had all of the features I listed above.
So, after deciding that I would use textile4j to Textilize my app, I followed these steps to get everything set up.
1. Copy textile4j jar to my
<grails-root>/lib
folder.
2. Created a
TextileCodec.groovy
file in
<grails-root>/grails-app/utils
folder with the following contents:
3. Used it in my code! I needed it for a view:
-
${quiz.problem.encodeAsTextile()}
Simple as that!
Phil Wilson | 24-Feb-07 at 6:56 pm | Permalink
Yeah I know, I suck. I do have all this stuff, but wanted to move it over to Sourceforge before I released it all. I really should do that….
Matt | 24-Feb-07 at 7:23 pm | Permalink
Phil,
I hardly think you suck, though I was shocked to not see a Jar file in there. I would be happy to help out if you want it.
Also, for the record, both libraries have only one real class, and in that only one real method, so there really is little to fuss over.
- Matt
links for 2008-01-05 | 05-Jan-08 at 2:27 am | Permalink
[...] thoughts.on.code :: Using Textile with Grails During the process of writing my first Grails application, Groovyquiz.com (coming soon), I needed a clean way to write the quiz text, and was generally not interested in writing everything as HTML. [...]