router.get('/', function(req, res, next) { res.render('index', { username: req.user && req.user.name }); });
Note that when rendering the 'index' view we construct the model with a username if it exists. Now this can be used on the view to change the rendering:
@html.block('content', function(model) { @if(!model.username) { <div class="u-center-block instructions"> <div class="u-center-block__content">You must log in to create events.</div> </div> } else { ... } })
Source code is available at bitbucket or you can play with the live test site.
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.