From: Brian Candler Date: 2009-11-16T21:51:59+09:00 Subject: Re: Traversing the contents of a proc (for a DSL) Siemen Baader wrote: > I'm playing with a small DSL for HTML, which should look like this. > > html { > head { title {"Hello World"} } > body { > h1 { "hello"} > p { > "text body" > "more text" > } > } > } > > If it is possible to recursively traverse through the statements in > each block, I could join the lines together with the + operator, and > the implementation would be fairly easy - just recursive calls that > return text. But it does not look like this is possible... Two string literals on the same line are concatenated - so in the above example you could get away with a simple pre-processor that joins the lines together in the right places. >> "foo" "bar" => "foobar" >> However this won't work for str1 str2 If this is what you want - i.e. each expression appearing on a line of its own has its value sent to the output string - then probably native Ruby is not the right tool. HAML, ERB and Cucumber are examples of DSLs where a non-Ruby syntax fits better. -- Posted via http://www.ruby-forum.com/.