Skip to content

Instantly share code, notes, and snippets.

@rblalock
Created August 18, 2012 19:40
Show Gist options
  • Save rblalock/3389272 to your computer and use it in GitHub Desktop.
Save rblalock/3389272 to your computer and use it in GitHub Desktop.
Alloy template controller
var Alloy = require('alloy'),
Backbone = Alloy.Backbone,
_ = Alloy._,
A$ = Alloy.A;
function Controller() {
require('alloy/controllers/' + <%= parentController %>).apply(this, Array.prototype.slice.call(arguments));
var $ = this;
var exports = {};
<%= exportsCode %>
<%= viewCode %>
// make all IDed elements in $.__views available right on the $ in a
// controller's internal code. Externally the IDed elements will
// be accessed with getView().
_.extend($, $.__views);
<%= controllerCode %>
// Extend the $ instance with all functions and properties
// defined on the exports object.
_.extend($, exports);
}
module.exports = Controller;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment