-
-
Save sam3k/9f5bc164bc6dfe8ecffd to your computer and use it in GitHub Desktop.
partial issue in nodejitsu
This file contains 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
/** @module Abstract Model of Home Model */ | |
var util = require('util'), | |
Page = require(MODELS + '/page'); | |
/** | |
* @constructor | |
* @extends Page | |
*/ | |
function Home() {} | |
/** | |
* Extend Home with Page | |
*/ | |
util.inherits(Home, Page); | |
/** | |
* Get the homepage | |
* | |
* @public | |
*/ | |
Home.prototype.index = function (/**Object*/ request, /** Function */ callback) { | |
var data, | |
_ = require(LIBS + '/lodash/lodash'), | |
_this = this, | |
Databank = require(DATABANK + '/home'), | |
home = new Databank(); | |
console.log('request.route.path: ' + request.route.path); | |
console.log('body partialize ' , _this.partialize(PARTIALS + '/home.html', request)); | |
console.log('hero partialize ' , _this.partialize(WIDGETS + '/hero/hero.html', request)); | |
data = { | |
url : request.route.path, | |
layout : 'layout-a', | |
cache : false, | |
partials : { | |
body : _this.partialize(PARTIALS + '/home.html', request), | |
hero : _this.partialize(WIDGETS + '/hero/hero.html', request) | |
}, | |
hero : { | |
title : 'Sam3k', | |
desc : 'My name is Samuel Roldan; I\'m a front-end developer and UI/UX enthusiast.', | |
lnk : { | |
href : '#meh', | |
title : 'Click Here' | |
} | |
} | |
}; | |
/** | |
* we only get this on server calls. client side calls assume | |
* we already have the layout on stage | |
*/ | |
if (!app.page.request.ajax(request)) { | |
_.extend(data, this.layout()); | |
data.partials.body = _this.partialize(PARTIALS + '/home.html', request); | |
data.partials.hero = _this.partialize(WIDGETS + '/hero/hero.html', request); | |
} | |
/** | |
* This data is always called whether the request is server/client side | |
*/ | |
home.index(function (_data) { | |
_.extend(data, _data); | |
callback(data); | |
}); | |
}; | |
module.exports = Home; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment