Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanbain committed Jan 28, 2012
0 parents commit f447f39
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source "http://rubygems.org"

gem "tilt", "~> 1.3.3"
10 changes: 10 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
GEM
remote: http://rubygems.org/
specs:
tilt (1.3.3)

PLATFORMS
x86-mingw32

DEPENDENCIES
tilt (~> 1.3.3)
10 changes: 10 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
require 'active_support/deprecation'
require 'active_support/dependencies'

ActiveSupport::Dependencies.autoload_paths << File.expand_path(File.join(Dir.pwd, 'lib'))

namespace :tilt do
task :contact_details do |t|
sh %{ ruby lib/contact_details.rb }
end
end
20 changes: 20 additions & 0 deletions lib/contact_details.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
require 'tilt'

contacts = {
"Email" => "nathan_bain@hotmail.com",
"Twitter" => "@nathanbain",
"Facebook" => "nathan.bain",
"Skype" => "nathanbainitv" }

context = Object.new
def context.title
"Contact Details"
end

template = Tilt.new("templates/contact_list.erb")

File.open "output/contact_me.html", "w" do |file|
file.write template.render(context) {
Tilt.new("templates/sites.erb").render(Object.new, contacts: contacts)
}
end
10 changes: 10 additions & 0 deletions templates/contact_list.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title><%= title %></title>
</head>
<body>
<%= yield %>
</body>
</html>
6 changes: 6 additions & 0 deletions templates/sites.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<h2>A few ways to contact me</h2>
<ul>
<% contacts.each do |name, id| %>
<li><b><%= name %></b> <%= id %></li>
<% end %>
</ul>

0 comments on commit f447f39

Please sign in to comment.