Dave Johnson on open web technologies, social software and software development
« Congrats | Main | Latest links: March... »
This is just a quick follow-up to my previous post on Pluggable renderers and scripting languages in Roller. It took me a while, but I finally made JRuby code work inside a Roller page template. Here's an example JRuby page template that displays most recent blog titles and text in HTML format.
Not the most beautiful thing in the world, I must admit. Any JRuby experts reading along? Is there a simple templating solution that will work in JRuby... something like Groovy Templates? And is there a way to map puts output to a java.io.Writer that will work via BSF?$out.println "<html><head>"
$out.println "<title>#{$model.weblog.name}</title>"
$out.println "</head><body>"
$out.println "<h1>#{$model.weblog.name}</h1>"
$model.weblogEntriesPager.entries.keySet().each {|day|
$model.weblogEntriesPager.entries.get(day).each {|entry|
$out.println "<h3>#{entry.title}</h3>"
$out.println "<p>#{entry.text}</p>"
}
}
$out.println "</body></html>"
Dave Johnson in Roller
05:46PM Mar 20, 2007
Comments [4]
Tags:
java
jruby
roller
« Congrats | Main | Latest links: March... »
This is just one entry in the weblog Blogging Roller. You may want to visit the main page of the weblog
Below are the most recent entries in the category Roller, some may be related to this entry.
Posted by Patrick Mueller on March 21, 2007 at 03:21 AM EDT #
As far as getting puts to go to a java.io.Writer, you could assign to $stdout an object that looks like a Ruby IO but forwards/delegates print/write calls to the Java Writer. Or you could construct the JRuby runtime outside of BSF and explicitly set the stdout stream to your writer -- see org.jruby.Ruby.newInstance(InputStream,PrintStream,PrintStream)
Posted by Nick Sieger on March 21, 2007 at 04:09 PM EDT #
Posted by Dave Johnson on March 21, 2007 at 05:03 PM EDT #
Posted by Charles Oliver Nutter on March 22, 2007 at 01:14 AM EDT #