Skip to content

Instantly share code, notes, and snippets.

@danshultz
Created March 15, 2013 00:51
Show Gist options
  • Select an option

  • Save danshultz/5166629 to your computer and use it in GitHub Desktop.

Select an option

Save danshultz/5166629 to your computer and use it in GitHub Desktop.
Simple ERB render function
def render(template, save_path, vars)
template_file = File.open("lib/templates/#{template}", 'r').read
erb = ERB.new(template_file)
results = erb.result(OpenStruct.new(vars).instance_eval { binding })
File.open(save_path, 'w+') { |file| file.write(results) }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment