mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-03 23:00:14 -05:00
Modified body_class helper
closes #591 - body_class helper returns archive-template class on archive pages - added to unit tests
This commit is contained in:
parent
859e20d8a3
commit
e43029e894
2 changed files with 7 additions and 2 deletions
|
@ -136,7 +136,9 @@ coreHelpers = function (ghost) {
|
|||
|
||||
ghost.registerThemeHelper('body_class', function (options) {
|
||||
var classes = [];
|
||||
if (!this.path || this.path === '/' || this.path === '') {
|
||||
if (_.isString(this.path) && this.path.match(/\/page/)) {
|
||||
classes.push('archive-template');
|
||||
} else if (!this.path || this.path === '/' || this.path === '') {
|
||||
classes.push('home-template');
|
||||
} else {
|
||||
classes.push('post-template');
|
||||
|
|
|
@ -154,13 +154,16 @@ describe('Core Helpers', function () {
|
|||
|
||||
it('can render class string for context', function () {
|
||||
var rendered1 = handlebars.helpers.body_class.call({path: '/'}),
|
||||
rendered2 = handlebars.helpers.body_class.call({path: '/a-post-title'});
|
||||
rendered2 = handlebars.helpers.body_class.call({path: '/a-post-title'}),
|
||||
rendered3 = handlebars.helpers.body_class.call({path: '/page/4'});
|
||||
|
||||
should.exist(rendered1);
|
||||
should.exist(rendered2);
|
||||
should.exist(rendered3);
|
||||
|
||||
rendered1.string.should.equal('home-template');
|
||||
rendered2.string.should.equal('post-template');
|
||||
rendered3.string.should.equal('archive-template');
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue