mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-10 23:36:14 -05:00
parent
7419e05b3a
commit
f4ac715f97
2 changed files with 14 additions and 1 deletions
|
@ -227,12 +227,17 @@ coreHelpers = function (ghost) {
|
|||
|
||||
ghost.registerThemeHelper('post_class', function (options) {
|
||||
var classes = ['post'],
|
||||
tags = this.post && this.post.tags ? this.post.tags : this.tags || [];
|
||||
tags = this.post && this.post.tags ? this.post.tags : this.tags || [],
|
||||
featured = this.post && this.post.featured ? this.post.featured : this.featured || false;
|
||||
|
||||
if (tags) {
|
||||
classes = classes.concat(tags.map(function (tag) { return 'tag-' + tag.slug; }));
|
||||
}
|
||||
|
||||
if (featured) {
|
||||
classes.push('featured');
|
||||
}
|
||||
|
||||
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());
|
||||
|
|
|
@ -197,6 +197,14 @@ describe('Core Helpers', function () {
|
|||
|
||||
rendered.string.should.equal('post');
|
||||
});
|
||||
|
||||
it('can render featured class', function () {
|
||||
var post = { featured: true },
|
||||
rendered = handlebars.helpers.post_class.call(post);
|
||||
|
||||
should.exist(rendered);
|
||||
rendered.string.should.equal('post featured');
|
||||
});
|
||||
});
|
||||
|
||||
describe('ghost_head Helper', function () {
|
||||
|
|
Loading…
Add table
Reference in a new issue