Skip to content

Instantly share code, notes, and snippets.

@mde
Created December 8, 2012 03:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mde/4238518 to your computer and use it in GitHub Desktop.
Save mde/4238518 to your computer and use it in GitHub Desktop.
Setting var in beforeFilter for use in view
// 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