Mega Code Archive

 
Categories / Ruby / Development
 

Embedded Ruby

# Embedded Ruby (ERB or eRuby) embeds arbitrary Ruby code in text files.  # The code is executed when the file is processed.  # ERB comes with the Ruby distribution.  # It's very common to embed code in HTML or XHTML. #!/usr/bin/env ruby require 'erb' person = "myValue!" temp = ERB.new( "Hello, <%= person %>" ) puts temp.result( binding ) # => Hello, myValue!