Skip to content

Commit

Permalink
7 - Passing Data to Views
Browse files Browse the repository at this point in the history
  • Loading branch information
hollylawly committed Aug 30, 2016
1 parent 7a27294 commit 61a8675
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
9 changes: 8 additions & 1 deletion app/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,14 @@ router.get('/', function(req, res) {

// route for our about page
router.get('/about', function(req, res) {
res.render('pages/about');
var users = [
{ name: 'Holly', email: '[email protected]', avatar: 'http://placekitten.com/300/300'},
{ name: 'Chris', email: '[email protected]', avatar: 'http://placekitten.com/400/400'},
{ name: 'Ado', email: '[email protected]', avatar: 'http://placekitten.com/500/500'},
{ name: 'Samantha', email: '[email protected]', avatar: 'http://placekitten.com/700/700'}
];

res.render('pages/about', { users: users });
});

router.get('/contact', function(req, res) {
Expand Down
11 changes: 10 additions & 1 deletion views/pages/about.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,14 @@

<%- contentFor('body') %>
<div class="jumbotron text-center">
About Page
<h1>The Team</h1>

<div class="row">
<% for (user of users) { %>
<div class="col-sm-3">
<h2><%= user.name %>
<img src="<%= user.avatar %>" alt="" class="img-responsive">
</div>
<% } %>
</div>
</div>

0 comments on commit 61a8675

Please sign in to comment.