Skip to content

Instantly share code, notes, and snippets.

View jankuca's full-sized avatar

Jan Kuča jankuca

  • Prague, Czech Republic
  • 13:00 (UTC +01:00)
View GitHub Profile
@jankuca
jankuca / tag-helpers.js
Last active August 29, 2015 14:21 — forked from ofstudio/heplers.js
var hbs = require('express-hbs'),
api = require('core/server/api'),
_ = require('lodash'),
async = require('express-hbs/lib/async'), // To redefine `registerAsyncHelper`
registerAsyncHelper;
// Redefine `registerAsyncHelper` from `express-hbs`
registerAsyncHelper = function (name, fn) {
hbs.handlebars.registerHelper(name, function (context, options) {
// Pass `[context, options]` as arg instead of `context` only
module.exports = function (Handlebars) {
/*! ******************************
Handlebars helpers
*******************************/
// debug helper
// usage: {{debug}} or {{debug someValue}}
// from: @commondream (http://thinkvitamin.com/code/handlebars-js-part-3-tips-and-tricks/)
Handlebars.registerHelper("debug", function(optionalValue) {
console.log("Current Context");
init: function (done) {
// 1
if (this.$session['user_id'] == null) {
return this.redirectTo('backend:sign:login');
}
// 2
this.$users.one(this.$session['user_id'], function (err, user) {
// 4
if (!err) {
this.current_user = user;
var darkside = require('darkside');
var SignController = function (users) {
darkside.base(darkside.ViewController, this);
this.$users = users;
};
require('util').inherits(SignController, darkside.ViewController);
var darkside = require('darkside');
var DashboardController = function (users) {
darkside.base(darkside.ViewController, this);
this.$users = users;
};
require('util').inherits(DashboardController, darkside.ViewController);