Merge pull request #612 from cobbspur/bodyclass

Modified body_class helper
This commit is contained in:
Hannah Wolfe 2013-09-02 12:57:46 -07:00
commit 40c3b7fe31
2 changed files with 7 additions and 2 deletions

View File

@ -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');

View File

@ -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');
});
});