nette/latte

`n:syntax` does not reset syntax after closing element tag

daun opened this issue · 2 comments

Version: 3.0.13

Bug Description

When using n:syntax on an element node, the closing tag does not reset the syntax. Any content after the closing element tag is treated as text.

Steps To Reproduce

In theory, this should resolve both outer {$var} and leave the inner {$var} untouched.

{$var} <div n:syntax="off">{$var}</div> {$var}

In reality, this is what's rendered:

hello <div>{$var}</div> {$var}

See fiddle f6d9e5b641 for a demonstration.

Expected Behavior

The content after the element should resume parsing normally and also print the second outer {$var}.

hello <div>{$var}</div> hello

Possible Solution

Not sure. Stumbled upon this by accident while trying to solve a similar situation in a custom tag, and wanted to check how the core handles this. Eager to learn the solution here :)

Interestingly, wrapping it in another div seems to reset the syntax for the outer element, however not for the inner element context. See fiddle 615314f99d for an example.

<div>
	{$var} <div n:syntax="off">{$var}</div> {$var}
</div>

{$var}

Which results in:

<div>
	hello <div>{$var}</div> {$var}
</div>

hello

Getting closer. There is a test for this scenario, but it passes because of a line break before the after variable. Removing the line breaks causes the issue.

Works and resolves both outer print statements:

{$var}
<div n:syntax="off">{$var}</div>
{$var}

Fails and ignores last print statement:

{$var} <div n:syntax="off">{$var}</div> {$var}