mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-25 20:03:12 +03:00
Merge pull request #524 from cobbspur/helpers
added ghost_head and ghost_foot helpers
This commit is contained in:
commit
c63012a678
@ -301,10 +301,9 @@ Ghost.prototype.initTheme = function (app) {
|
|||||||
app.set('views', self.paths().adminViews);
|
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/assets')));
|
||||||
app.use('/public', express['static'](path.join(__dirname, '/client')));
|
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(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')));
|
app.use('/content/images', express['static'](path.join(__dirname, '/../content/images')));
|
||||||
next();
|
next();
|
||||||
};
|
};
|
||||||
|
@ -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]
|
* [ description]
|
||||||
*
|
*
|
||||||
|
@ -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 () {
|
describe('Navigation Helper', function () {
|
||||||
|
|
||||||
it('has loaded nav helper', function () {
|
it('has loaded nav helper', function () {
|
||||||
|
Loading…
Reference in New Issue
Block a user