',
'{% elsif b %}',
'
',
'{% else %}',
'
',
'{% endif %}',
'{{ content_for_layout }}',
'
',
'
',
'',
'',
].join('\n');
it('throws on an element opened in every branch and closed after endif, without the option', () => {
expect(() => toLiquidHtmlAST(LAYOUT, STRICT)).toThrow(
"Attempting to close HtmlElement 'div' before HtmlElement 'body' was closed",
);
});
it('parses the close as a dangling marker inside the enclosing element', () => {
expect(parseOutline(LAYOUT)).toEqual([
'',
'
',
' {% if %}',
' branch (first)',
'
(open)',
' branch elsif',
'
(open)',
' branch else',
'
(open)',
' {{ }}',
'
(dangling)',
'
',
]);
});
it('parses a close at the document level the same way', () => {
const source = '{% if a %}
{% else %}
{% endif %}hi
';
expect(() => toLiquidHtmlAST(source, STRICT)).toThrow(
"Attempting to close HtmlElement 'div' before it was opened",
);
expect(parseOutline(source)).toEqual([
'{% if %}',
' branch (first)',
'
(open)',
' branch else',
'
(open)',
'
(dangling)',
]);
});
it('parses a close in a loop body the same way', () => {
const source =
'