From 75f019acd2a1be47be106dfc295d0f5157bd54c3 Mon Sep 17 00:00:00 2001 From: tgabi333 Date: Mon, 21 Jan 2019 21:28:57 +0100 Subject: [PATCH] fix for not autoescaping includes having a parent --- src/twig.core.js | 3 ++- test/test.core.js | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/twig.core.js b/src/twig.core.js index cd4e7ee9..87802f0f 100644 --- a/src/twig.core.js +++ b/src/twig.core.js @@ -1290,7 +1290,8 @@ module.exports = function (Twig) { that.parent = ext_template; return that.parent.renderAsync(that.context, { - blocks: that.blocks + blocks: that.blocks, + isInclude: true }); } diff --git a/test/test.core.js b/test/test.core.js index dc7ee400..cdaf9221 100644 --- a/test/test.core.js +++ b/test/test.core.js @@ -382,6 +382,16 @@ describe("Twig.js Core ->", function() { }).render({ value: "&" }).should.equal('&& & & & &&'); }); + it("should not autoescape includes having a parent", function() { + twig({id: 'included3', data: '{% extends "parent2" %}{% block body %}& {{ value }} &{% endblock %}'}); + twig({id: 'parent2', data: '&& {% block body %}{% endblock body %} &&'}); + twig({ + allowInlineIncludes: true, + autoescape: true, + data: '&&& {% include "included3" %} &&&' + }).render({ value: "&" }).should.equal('&&& && & & & && &&&'); + }); + it("should support autoescape option with alternative strategy", function() { twig({ autoescape: 'js',