Blog An exploration of the art and
craft of software development

Builder output

Posted by Marty Haught on Tuesday, January 22, 2008

I ran into a strange issue recently when outputting a table row constructed through Builder::XmlMarkup. We noticed as the output of our markup had an extra tag at the end. While you can guess what this is, how it was happening what a bit more mysterious as we’ve used Builder before and hadn’t seen this extra tag. As you may know Builder will create xml tags based on the methods you invoke on it, which is really cool. When we include the Builder object in a double-quoted string the to_s method was called on our behalf that appended the extra tag. The solution wasn’t all that difficult to figure out once you read the Builder rdoc but I hadn’t seen mention of this technique in other tutorials on Builder. The target! method will get you the output you need without appending any other tags.

blog comments powered by Disqus