Merge pull request #524 from cobbspur/helpers

added ghost_head and ghost_foot helpers
This commit is contained in:
Hannah Wolfe 2013-08-25 06:41:34 -07:00
commit c63012a678
3 changed files with 43 additions and 2 deletions

View File

@ -301,10 +301,9 @@ Ghost.prototype.initTheme = function (app) {
app.set('views', self.paths().adminViews);
app.use('/public', express['static'](path.join(__dirname, '/client/assets')));
app.use('/public', express['static'](path.join(__dirname, '/client')));
app.use('/shared', express['static'](path.join(__dirname, '/shared/')));
}
app.use(express['static'](self.paths().activeTheme));
app.use('/shared', express['static'](path.join(__dirname, '/shared')));
app.use('/content/images', express['static'](path.join(__dirname, '/../content/images')));
next();
};

View File

@ -127,7 +127,25 @@ coreHelpers = function (ghost) {
});
});
ghost.registerThemeHelper('ghost_head', function (options) {
var head = [];
head.push('<meta name="generator" content="Ghost ' + this.version + '" />');
return ghost.doFilter('ghost_head', head, function (head) {
var headString = _.reduce(head, function (memo, item) { return memo + ' ' + item; }, '');
return new hbs.handlebars.SafeString(headString.trim());
});
});
ghost.registerThemeHelper('ghost_foot', function (options) {
var foot = [];
foot.push('<script src="/shared/vendor/jquery/jquery.js"></script>');
return ghost.doFilter('ghost_foot', foot, function (foot) {
var footString = _.reduce(foot, function (memo, item) { return memo + ' ' + item; }, '');
return new hbs.handlebars.SafeString(footString.trim());
});
});
/**
* [ description]
*

View File

@ -177,6 +177,30 @@ describe('Core Helpers', function () {
});
});
describe('ghost_head Helper', function () {
it('has loaded ghost_head helper', function () {
should.exist(handlebars.helpers.ghost_head);
});
it('returns meta tag string', function () {
var rendered = handlebars.helpers.ghost_head.call({version: "0.3"});
should.exist(rendered);
rendered.string.should.equal('<meta name="generator" content="Ghost 0.3" />');
});
});
describe('ghost_foot Helper', function () {
it('has loaded ghost_foot helper', function () {
should.exist(handlebars.helpers.ghost_foot);
});
it('returns meta tag string', function () {
var rendered = handlebars.helpers.ghost_foot.call();
should.exist(rendered);
rendered.string.should.equal('<script src="/shared/vendor/jquery/jquery.js"></script>');
});
});
describe('Navigation Helper', function () {
it('has loaded nav helper', function () {