mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-12 16:14:25 +03:00
Merge pull request #5859 from ErisDS/plural
Add replacement for zero in plural helper
This commit is contained in:
commit
48919a96c0
@ -20,7 +20,7 @@ plural = function (context, options) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (context === 0) {
|
if (context === 0) {
|
||||||
return new hbs.handlebars.SafeString(options.hash.empty);
|
return new hbs.handlebars.SafeString(options.hash.empty.replace('%', context));
|
||||||
} else if (context === 1) {
|
} else if (context === 1) {
|
||||||
return new hbs.handlebars.SafeString(options.hash.singular.replace('%', context));
|
return new hbs.handlebars.SafeString(options.hash.singular.replace('%', context));
|
||||||
} else if (context >= 2) {
|
} else if (context >= 2) {
|
||||||
|
@ -31,6 +31,20 @@ describe('{{plural}} helper', function () {
|
|||||||
rendered.string.should.equal(expected);
|
rendered.string.should.equal(expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('will show no-value string with placement', function () {
|
||||||
|
var expected = '0 Posts',
|
||||||
|
rendered = helpers.plural.call({}, 0, {
|
||||||
|
hash: {
|
||||||
|
empty: '% Posts',
|
||||||
|
singular: '% Post',
|
||||||
|
plural: '% Posts'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
should.exist(rendered);
|
||||||
|
rendered.string.should.equal(expected);
|
||||||
|
});
|
||||||
|
|
||||||
it('will show singular string', function () {
|
it('will show singular string', function () {
|
||||||
var expected = '1 Post',
|
var expected = '1 Post',
|
||||||
rendered = helpers.plural.call({}, 1, {
|
rendered = helpers.plural.call({}, 1, {
|
||||||
|
Loading…
Reference in New Issue
Block a user