8000 Merge pull request #606 from tgabi333/master · twigjs/twig.js@ed71272 · GitHub
[go: up one dir, main page]

Skip to content

Commit ed71272

Browse files
authored
Merge pull request #606 from tgabi333/master
fix for not autoescaping includes having a parent
2 parents 35cbb35 + 75f019a commit ed71272

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/twig.core.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1290,7 +1290,8 @@ module.exports = function (Twig) {
12901290
that.parent = ext_template;
12911291

12921292
return that.parent.renderAsync(that.context, {
1293-
blocks: that.blocks
1293+
blocks: that.blocks,
1294+
isInclude: true
12941295
});
12951296
}
12961297

test/test.core.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,16 @@ describe("Twig.js Core ->", function() {
382382
}).render({ value: "&" }).should.equal('&& & & & &&');
383383
});
384384

385+
it("should not autoescape includes having a parent", function() {
386+
twig({id: 'included3', data: '{% extends "parent2" %}{% block body %}& {{ value }} &{% endblock %}'});
387+
twig({id: 'parent2', data: '&& {% block body %}{% endblock body %} &&'});
388+
twig({
389+
allowInlineIncludes: true,
390+
autoescape: true,
391+
data: '&&& {% include "included3" %} &&&'
392+
}).render({ value: "&" }).should.equal('&&& && & & & && &&&');
393+
});
394+
385395
it("should support autoescape option with alternative strategy", function() {
386396
twig({
387397
autoescape: 'js',

0 commit comments

Comments
 (0)
0