mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-24 19:33:02 +03:00
Allow HTML inside tag prefix/suffix
closes #2123 - Return hbs.Safestring - Manually escape joined tags - Added test
This commit is contained in:
parent
2beba7f1d7
commit
f468b464a6
@ -181,10 +181,10 @@ coreHelpers.tags = function (options) {
|
||||
tagNames = _.pluck(this.tags, 'name');
|
||||
|
||||
if (tagNames.length) {
|
||||
output = prefix + tagNames.join(separator) + suffix;
|
||||
output = prefix + _.escape(tagNames.join(separator)) + suffix;
|
||||
}
|
||||
|
||||
return output;
|
||||
return new hbs.handlebars.SafeString(output);
|
||||
};
|
||||
|
||||
// ### Content Helper
|
||||
|
@ -640,6 +640,18 @@ describe('Core Helpers', function () {
|
||||
String(rendered).should.equal('on haunted, ghost forever');
|
||||
});
|
||||
|
||||
it('can add a prefix and suffix with HTML', function () {
|
||||
var tags = [{name: 'haunted'}, {name: 'ghost'}],
|
||||
rendered = handlebars.helpers.tags.call(
|
||||
{tags: tags},
|
||||
{"hash": {suffix: ' •', prefix: '… '}}
|
||||
);
|
||||
|
||||
should.exist(rendered);
|
||||
|
||||
String(rendered).should.equal('… haunted, ghost •');
|
||||
});
|
||||
|
||||
it('does not add prefix or suffix if no tags exist', function () {
|
||||
var rendered = handlebars.helpers.tags.call(
|
||||
{},
|
||||
@ -1032,4 +1044,4 @@ describe('Core Helpers', function () {
|
||||
}).then(null, done);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user