Created
January 16, 2015 00:50
-
-
Save rickbacci/c27fcb4a31b0cbca0831 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'erb' | |
include ERB::Util | |
@items = ['foo', 'bar', 'baz'] | |
weekday = Time.now.strftime('%A') | |
template = %Q{ | |
<DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" | |
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | |
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> | |
<title>Shopping List for <%= weekday %></title> | |
</head> | |
<body> | |
<h1>Shopping List for <%= weekday %></h1> | |
<p>You need to buy:</p> | |
<ul> | |
<% for @item in @items %> | |
<li><%= @item %></li> | |
<% end %> | |
</ul> | |
</body> | |
</html> | |
} | |
renderer = ERB.new(template) | |
puts output = renderer.result() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment