Thursday, March 17, 2011

I started using eRuby to create JasperReport JRXML files

All of a sudden I knew, I would immediately need a template mechanism. During the last "Stuttgart.pm" meet-up Mason got mentioned, but I was already a little familiar with eRuby, so I gave it a try, and it was just the right thing to do. The XML file to handle got smaller and smaller and smaller – really, really nice to see.

Update 2011-03-25:
A few days later I am really rather satisfied with this decision.
Of course: eRuby XML files are no longer clean XML, so they are not supported by any editing mode (apart from "text-mode") in emacs, but then that's not too terrible.

Update 2011-04-20:
Of course (again) being able to deal with eRuby XML files as XML files within nxml-mode would be a charm. There are 2 obstacles to overcome:

In order to interpolate ruby expressions into XML this syntax is used:

y="<%=y0+13%>"

but nxml-mode does not accept that for a legal XML attribute value.

Lines starting with '%' are for ruby code, nxml-mode should / may consider them as comments:

% y0 = 97

No comments: