mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-03-11 02:12:21 -05:00
Merge pull request #525 from cobbspur/helpers
renamed helpers to body_class and post_class
This commit is contained in:
commit
da0ab62989
2 changed files with 13 additions and 13 deletions
|
@ -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());
|
||||
});
|
||||
|
|
|
@ -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');
|
||||
|
|
Loading…
Add table
Reference in a new issue