Ruby templating with ERB

ERB comes by default with ruby, you only need to require it:

require 'erb'

Create a template file ./template/steak.erb:

A large steak, <%= @how_done %>, please!
<%- 3.times do -%>
And another!
<%- end -%>

And read it into a variable:

tempalte = File.read('./template/steak.erb')

Now you can bind instance variables and pass them to the renderer:

renderer = ERB.new(template, nil, '-')

@how_done = 'medium rare'
puts renderer.result(binding)