Hey guys I am generating a file using erb and an input template file.

def fileSafeCreateHeader( filename )

  puts "RMake> Creating header file: " + filename

  rmake_loc = File.expand_path( File.dirname( __FILE__ ) )
  lines = IO.readlines( "#{rmake_loc}/templates/title.trb" )

  File.open( filename, "w+" ) do |f|
    expanded_line = ERB.new( lines.join("\n") , nil, "%<>" )
    f.puts expanded_line.result
  end

end

However when I run my script I get an error saying 'filename' is not
defined, when you can see it is! What's going on here?

RMake> Creating header file: def.h
(erb):3:in `<main>': undefined local variable or method `filename' for
main:Object (NameError)
        from /usr/local/lib/ruby/1.9.1/erb.rb:838:in `eval'
        from /usr/local/lib/ruby/1.9.1/erb.rb:838:in `result'


-- 
Kind Regards,
Rajinder Yadav

SafetyNet Test Driven Development
http://safetynet.devmentor.org