diff --git a/tests/common/contentType.compatibility.phpt b/tests/common/contentType.compatibility.phpt index 9162f68975..3e9f12bfa0 100644 --- a/tests/common/contentType.compatibility.phpt +++ b/tests/common/contentType.compatibility.phpt @@ -293,7 +293,7 @@ $latte->setLoader(new Latte\Loaders\StringLoader([ 'context1a' => '
{block html|noescape}
{block html|upper}
{block html|stripHtml|upper}
', + 'context2' => '
', 'context2a' => '', 'context6' => '', 'context6a' => '', @@ -310,7 +310,7 @@ Assert::exception(function () use ($latte) { }, Latte\RuntimeException::class, 'Filter |upper is called with incompatible content type HTML, try to prepend |stripHtml.'); Assert::same('" <
', $latte->renderToString('context1c')); -Assert::same('', $latte->renderToString('context2')); +Assert::same('
', $latte->renderToString('context2')); Assert::same('', $latte->renderToString('context2a')); Assert::same('', $latte->renderToString('context6')); @@ -326,7 +326,7 @@ $latte->setLoader(new Latte\Loaders\StringLoader([ 'context1a' => '{var $n=html}{block $n|noescape}
{var $n=html}{block $n|upper}
{var $n=html}{block $n|stripHtml|upper}
', + 'context2' => '
', 'context2a' => '', 'context6' => '', 'context6a' => '', @@ -343,7 +343,7 @@ Assert::exception(function () use ($latte) { }, Latte\RuntimeException::class, 'Filter |upper is called with incompatible content type HTML, try to prepend |stripHtml.'); Assert::same('" <
', $latte->renderToString('context1c')); -Assert::same('', $latte->renderToString('context2')); +Assert::same('
', $latte->renderToString('context2')); Assert::same('', $latte->renderToString('context2a')); Assert::same('', $latte->renderToString('context6')); @@ -359,7 +359,7 @@ $latte->setLoader(new Latte\Loaders\StringLoader([ 'context1a' => '{block|noescape}
{block|upper}
{block|stripHtml|upper}
', + 'context2' => '
', 'context2a' => '', 'context6' => '', 'context6a' => '', @@ -376,7 +376,7 @@ Assert::exception(function () use ($latte) { }, Latte\RuntimeException::class, 'Filter |upper is called with incompatible content type HTML, try to prepend |stripHtml.'); Assert::same('" <
', $latte->renderToString('context1c')); -Assert::same('', $latte->renderToString('context2')); +Assert::same('
', $latte->renderToString('context2')); Assert::same('', $latte->renderToString('context2a')); Assert::same('', $latte->renderToString('context6')); diff --git a/tests/tags/contentType.phpt b/tests/tags/contentType.phpt index ea1ee1e979..9d47f07cf9 100644 --- a/tests/tags/contentType.phpt +++ b/tests/tags/contentType.phpt @@ -26,6 +26,21 @@ Assert::exception(function () use ($latte) { $latte->createTemplate('even ? 'even' : null])) ? ' class="' . LR\Filters::escapeHtmlAttr(implode(" ", array_unique($ʟ_tmp))) . '"' : "" /* line %d% */; + echo '>'; + echo LR\Filters::escapeHtmlText($foo) /* line %d% */; + echo '
+'; + $iterations++; + } + $iterator = $ʟ_it = $ʟ_it->getParent(); + echo ' +n:class
+ +n:class empty
+ +n:class with BEM
+'; +%A% diff --git a/tests/tags/n-attr.phpt b/tests/tags/n-attr.phpt new file mode 100644 index 0000000000..acd8d803d1 --- /dev/null +++ b/tests/tags/n-attr.phpt @@ -0,0 +1,65 @@ +setLoader(new Latte\Loaders\StringLoader); + +$template = <<<'EOD' + ++ +
+ +EOD; + +Assert::match( + <<<'XX' +%A% + echo ' +
'hello', 'lang' => isset($lang) ? $lang : null]; + echo LR\Filters::htmlAttributes(isset($ʟ_tmp[0]) && is_array($ʟ_tmp[0]) ? $ʟ_tmp[0] : $ʟ_tmp) /* line 2 */; + echo '>
+ +'hello']]; + echo LR\Filters::htmlAttributes(isset($ʟ_tmp[0]) && is_array($ʟ_tmp[0]) ? $ʟ_tmp[0] : $ʟ_tmp) /* line 4 */; + echo '>
+'; +%A% +XX +, + $latte->compile($template) +); + +Assert::match( + <<<'XX' + ++ +
+XX +, + $latte->renderToString($template) +); + + +Assert::exception(function () use ($latte) { + $latte->compile(''); +}, Latte\CompileException::class, 'Missing arguments in n:attr'); + + +Assert::exception(function () use ($latte) { + $latte->compile(''); +}, Latte\CompileException::class, 'Unknown attribute n:inner-attr'); diff --git a/tests/tags/n-class.phpt b/tests/tags/n-class.phpt new file mode 100644 index 0000000000..e9fe7a031b --- /dev/null +++ b/tests/tags/n-class.phpt @@ -0,0 +1,68 @@ +setLoader(new Latte\Loaders\StringLoader); + +$template = <<<'EOD' + +{foreach [1,2,3] as $foo} + item +{/foreach} + +
{$foo}
+ +n:class
+ +n:class empty
+ +n:class with BEM
+ +EOD; + +Assert::matchFile( + __DIR__ . '/expected/n-class.phtml', + $latte->compile($template) +); + +Assert::match( + <<<'XX' + + item + item + item + +1
+2
+3
+ +n:class
+ +n:class empty
+ +n:class with BEM
+XX +, + $latte->renderToString($template) +); + + +Assert::exception(function () use ($latte) { + $latte->compile(''); +}, Latte\CompileException::class, 'Missing arguments in n:class'); + + +Assert::exception(function () use ($latte) { + $latte->compile(''); +}, Latte\CompileException::class, 'Unknown attribute n:inner-class'); diff --git a/tests/tags/n-tag.phpt b/tests/tags/n-tag.phpt index a675ff26a6..37f095645e 100644 --- a/tests/tags/n-tag.phpt +++ b/tests/tags/n-tag.phpt @@ -1,7 +1,7 @@