Skip to content

Commit

Permalink
introduce mustache templates
Browse files Browse the repository at this point in the history
  • Loading branch information
aamyot authored and aamyot committed Jun 22, 2015
1 parent 16af27f commit 1495982
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 2 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ source 'https://rubygems.org'

gem 'rack'
gem 'thin'
gem 'mustache'

group :test do
gem 'rspec'
Expand Down
2 changes: 2 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ GEM
domain_name (~> 0.5)
json (1.8.3)
mime-types (2.6.1)
mustache (1.0.1)
netrc (0.10.3)
rack (1.6.4)
rack-test (0.6.3)
Expand Down Expand Up @@ -61,6 +62,7 @@ PLATFORMS

DEPENDENCIES
coveralls
mustache
rack
rack-test
rake
Expand Down
4 changes: 3 additions & 1 deletion app/controller/home.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
require './app/view/views'

class Home
def call(env)
[200, {"Content-Type" => "text/html"}, ["Hello Yose", "<a id='repository-link' href='http://github.com/aamyot/yose-ruby'>Source</a>"]]
[200, {"Content-Type" => "text/html"}, View::Home.render]
end
end
26 changes: 26 additions & 0 deletions app/view/home.mustache
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<html>

<head>
<title>YoseTheGame</title>
</head>

<body>
<div class="container">
<h2>Hello Yose</h2>

<div id="challenges">
<span>Challenges</span>
<ul>
<li><a id="ping-challenge-link" href="/ping">Ping</a></li>
</ul>

</div>

<div id="portfolio">
<a id="repository-link" href="http://github.com/aamyot/yose-ruby">Source</a>
<a id="contact-me-link" href="http://ca.linkedin.com/in/alexandreamyot">Contact</a>
</div>
</div>

</body>
</html>
10 changes: 10 additions & 0 deletions app/view/views.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
require 'mustache'

module View

class Home < Mustache
self.template_file = "./app/view/home.mustache"

end

end
2 changes: 1 addition & 1 deletion spec/challenges/start_challenge_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def app
end

it "links to its repository" do
expect(last_response.body).to include("<a id='repository-link' href='http://github.com/aamyot/yose-ruby'>Source</a>")
expect(last_response.body).to include("<a id=\"repository-link\" href=\"http://github.com/aamyot/yose-ruby\">Source</a>")
end
end

Expand Down

0 comments on commit 1495982

Please sign in to comment.