Skip to content

Commit

Permalink
Add test for issue twigjs#767
Browse files Browse the repository at this point in the history
  • Loading branch information
willrowe committed Oct 3, 2022
1 parent b508683 commit e35788f
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 e35788f

Please sign in to comment.