Skip to content

Commit

Permalink
Added example usage of cookies to hello app.
Browse files Browse the repository at this point in the history
  • Loading branch information
thatismatt committed Jul 6, 2010
1 parent 5bb8cf9 commit ce09c60
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
12 changes: 12 additions & 0 deletions examples/hello/controllers/home.js
Expand Up @@ -19,3 +19,15 @@ this.another = function() {
this.redir = function() {
return redirect('/product/details/1');
};

this.cookie = function() {
var aCookie = this.cookie.get('a') === 'red' ? 'blue' : 'red';
var bCookie = (parseInt(this.cookie.get('b'), 10) || 0) + 1;
this.cookie.set('a', aCookie);
this.cookie.set('b', bCookie);
return view({
title: 'Cookies',
a: aCookie,
b: bCookie
});
};
6 changes: 6 additions & 0 deletions examples/hello/views/home/cookie.html
@@ -0,0 +1,6 @@
<p>
The cookie a's value is: <%= a %>
</p>
<p>
The cookie b's value is: <%= b %>
</p>
1 change: 1 addition & 0 deletions examples/hello/views/master.html
Expand Up @@ -11,6 +11,7 @@ <h1><a href="/"><%= title %></a></h1>
<li><a href="/home/another">An action sharing a view</a></li>
<li><a href="/product">List of products</a></li>
<li><a href="/error">Throw an error</a></li>
<li><a href="/home/cookie">Cookie example</a></li>
</ul>
<div class="main">
<%= main %>
Expand Down

0 comments on commit ce09c60

Please sign in to comment.