Skip to content

Commit

Permalink
Merge pull request #837 from willrowe/test/issue-767
Browse files Browse the repository at this point in the history
Add test for issue #767
  • Loading branch information
willrowe authored Oct 5, 2022
2 parents b508683 + e35788f commit 22e7a38
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test/test.embed.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,4 +162,21 @@ describe('Twig.js Embed ->', function () {
'data': '{% include "include.twig" %} {% include "include.twig" %}',
}).render().should.equal('embed embed');
});

it('should work when rendering the same include multiple times with embedded block', function () {
twig({
'data': '<div><h1>component a</h2>{% block content %}{% endblock %}</div>',
'id': 'component-a.html.twig',
});

twig({
'data': '{% embed "component-a.html.twig" %}{% block content %}<p>component b</p>{% endblock %}{% endembed %}',
'id': 'component-b.html.twig',
});

twig({
'allowInlineIncludes': true,
'data': '{% include "component-b.html.twig" %}{% include "component-b.html.twig" %}',
}).render().trim().should.equal('<div><h1>component a</h2><p>component b</p></div><div><h1>component a</h2><p>component b</p></div>');
});
});

0 comments on commit 22e7a38

Please sign in to comment.