Created
December 8, 2012 03:56
-
-
Save mde/4238518 to your computer and use it in GitHub Desktop.
Setting var in beforeFilter for use in view
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Application controller | |
var Application = function () { | |
this.before(function () { | |
geddy.log.info('setting foo'); | |
this.foo = 'BAR'; | |
}); | |
}; | |
exports.Application = Application; | |
// Main controller | |
var Main = function () { | |
this.index = function (req, resp, params) { | |
geddy.log.info('>>>> ' + this.foo); | |
this.respond(params, { | |
format: 'html' | |
, template: 'app/views/main/index' | |
}); | |
}; | |
}; | |
exports.Main = Main; | |
// app/views/main/index.html.ejs | |
<%= foo %> | |
<!-- Lets talk about geddy --> | |
<div class="hero-unit geddy-welcome-box"> | |
<h1>Hello, World!</h1> | |
<p>You've created a Geddy app and your server is running. If you already know what you're doing, feel free to jump into your app logic, if not...</p> | |
<p><%- linkTo('Lets get you started »', 'http://geddyjs.org/tutorial.html', {class: 'btn btn-primary btn-large'}) %></p> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment