From: Einar Buffer <_ebuffer_@...> Date: 2004-03-23T18:14:38+09:00 Subject: newbie erb question Hi, I'm trying to use some erb templates to generate some code with ruby. It's not going too well - in my template, I have something like: ....code template in plain text... <% code_lines.each { |line| print line } %> ....more plain text code... I try to capture the generated code inside my ruby script like this: File.open('C:\Templates\MyCodeTemplate.erb') { |fh| erb = ERB:new(fh.read) gen_code = erb.result(binding) # Just to see the generated output. puts gen_code } I would like the lines in code_lines to be returned to the calling ruby code with the rest of the template code, but instead it goes to stdout! So all my actual code lines are dumped directly to screen instead of being included in the result being returned to the gen_code variable. What am I doing wrong? Is there a simple tutorial for ERB in english somewhere? I'm using ruby 1.8.1 with erb 2.0.4. Thanks a lot! -- "If it was so, it might be; and if it were so, it would be; but as it isn't, it ain't. That's logic" -- Lewis Carroll