renamed helpers to body_class and post_class

closes #508

- changed bodyclass helper to body_class and updated unit test
- changed postclass helper to post_class and updated unit test
This commit is contained in:
cobbspur 2013-08-25 14:49:57 +01:00
parent fafead5718
commit ce0f1aae46
2 changed files with 13 additions and 13 deletions

View File

@ -103,7 +103,7 @@ coreHelpers = function (ghost) {
});
ghost.registerThemeHelper('bodyclass', function (options) {
ghost.registerThemeHelper('body_class', function (options) {
var classes = [];
if (!this.path || this.path === '/' || this.path === '') {
classes.push('home-template');
@ -111,17 +111,17 @@ coreHelpers = function (ghost) {
classes.push('post-template');
}
return ghost.doFilter('bodyclass', classes, function (classes) {
return ghost.doFilter('body_class', classes, function (classes) {
var classString = _.reduce(classes, function (memo, item) { return memo + ' ' + item; }, '');
return new hbs.handlebars.SafeString(classString.trim());
});
});
ghost.registerThemeHelper('postclass', function (options) {
ghost.registerThemeHelper('post_class', function (options) {
var classes = ['post'];
// TODO: add tag names once we have them
return ghost.doFilter('postclass', classes, function (classes) {
return ghost.doFilter('post_class', classes, function (classes) {
var classString = _.reduce(classes, function (memo, item) { return memo + ' ' + item; }, '');
return new hbs.handlebars.SafeString(classString.trim());
});

View File

@ -140,21 +140,21 @@ describe('Core Helpers', function () {
});
});
describe('Bodyclass Helper', function () {
it('has loaded bodyclass helper', function () {
should.exist(handlebars.helpers.bodyclass);
describe('body_class Helper', function () {
it('has loaded body_class helper', function () {
should.exist(handlebars.helpers.body_class);
});
it('can render class string', function () {
var rendered = handlebars.helpers.bodyclass.call({});
var rendered = handlebars.helpers.body_class.call({});
should.exist(rendered);
rendered.string.should.equal('home-template');
});
it('can render class string for context', function () {
var rendered1 = handlebars.helpers.bodyclass.call({path: '/'}),
rendered2 = handlebars.helpers.bodyclass.call({path: '/a-post-title'});
var rendered1 = handlebars.helpers.body_class.call({path: '/'}),
rendered2 = handlebars.helpers.body_class.call({path: '/a-post-title'});
should.exist(rendered1);
should.exist(rendered2);
@ -164,13 +164,13 @@ describe('Core Helpers', function () {
});
});
describe('Postclass Helper', function () {
describe('post_class Helper', function () {
it('has loaded postclass helper', function () {
should.exist(handlebars.helpers.postclass);
should.exist(handlebars.helpers.post_class);
});
it('can render class string', function () {
var rendered = handlebars.helpers.postclass.call({});
var rendered = handlebars.helpers.post_class.call({});
should.exist(rendered);
rendered.string.should.equal('post');