8000 The raw filter return a new Markup(content) which may itself return c… · drzraf/twig.js@7658a92 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7658a92

Browse files
author
Raphaël Droz
committed
The raw filter return a new Markup(content) which may itself return content
if content is the empty string. The resulting output is [Object] instead of the expected empty string.
1 parent 39680b8 commit 7658a92

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/twig.core.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1443,7 +1443,7 @@ module.exports = function (Twig) {
14431443
*/
14441444

14451445
Twig.Markup = function (content, strategy) {
1446-
if (typeof content !== 'string' || content.length === 0) {
1446+
if (typeof content !== 'string') {
14471447
return content;
14481448
}
14491449

test/test.filters.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -778,6 +778,12 @@ describe('Twig.js Filters ->', function () {
778778
value: '<test>&</test>'
779779
}).should.equal('<test>&</test>');
780780
});
781+
782+
it('should output an empty string', function () {
783+
const template = twig({data: '{{ value|raw }}'});
784+
template.render({value: ''}).should.equal('');
785+
});
786+
781787
});
782788

783789
describe('round ->', function () {

0 commit comments

Comments
 (0)
0