Allow HTML inside tag prefix/suffix

closes #2123
- Return hbs.Safestring
- Manually escape joined tags
- Added test
This commit is contained in:
Fabian Becker 2014-02-08 12:53:28 +00:00
parent 2beba7f1d7
commit f468b464a6
2 changed files with 15 additions and 3 deletions

View File

@ -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

View File

@ -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);
});
});
});
});