Lazyweb: Is there a Ruby template engine like Genshi or Kid?
Ruby has a wide variety of HTML/XML templating engines, but none of the ones I’ve found work the way I’d like. It’s quite possible I’ve overlooked some, though.
My current gold standard for templaters is the Python library Genshi (which was inspired by Kid)—what I like about these is that your templates are valid XML: the parameters and control structures are expressed as special XML attributes and tags. This makes it easy to edit your templates in syntax-checking XML editors, and guarantees that your app serves valid XML or HTML.
But as I said, none of the Ruby template engines I’ve seen work this way. They’re all either generic macro systems that intermix markup and Ruby (like ERB), or they’re ruby APIs that output markup (like Builder, HAML and Markaby). I don’t really like either approach.
If you’ve got a good suggestion, I’ve got a gold star ready to stick on your forehead!
December 20th, 2008 at 2:10 PM
How about a new approach: unobtrusive scripting, like what the JS folks have learnt.. http://www.vimeo.com/1836815
December 22nd, 2008 at 8:52 AM
@choonkeat: you’re lucky jens isn’t jwz…
December 24th, 2008 at 1:38 PM
Hi Jens-
I actually kind of like the fact that Builder rxml is ruby script. The interpreter takes care of ensuring it’s generating valid XML. I’m already writing ruby, so have a ruby code editor / syntax highlighting / etc, and so don’t need to deal with an XML editor, with all its unsightly verbose XML-ish-ness.
And I can factor out my generation code using partials for DRYness, or not for readability as I like.
December 24th, 2008 at 6:41 PM
@aaron sorry i’m not aware what’s the consequence if that’s the case?
December 24th, 2008 at 6:55 PM
jwz is another blogger, and he’s famous for being extremely rude to people who answer his technical questions with alternate approaches rather than direct solutions.