I need ERB (Ruby\'s templating system) for templating of non-HTML files. (Instead, I want to use it for source files such as .java, .cs, ...)>
If you can switch ERB to Erubis, your problem solving is as simple as:
require 'erubis' template = File.read("sample_file.erb") template = Erubis::Eruby.new(template) template.result(:your_variable => "sample")