mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-12 10:26:32 +00:00
Merge branch '3.x' into 4.x
* 3.x: Fix tests Deprecate the spaceless filter
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
``spaceless``
|
||||
=============
|
||||
|
||||
.. warning::
|
||||
|
||||
The ``spaceless`` filter is deprecated as of Twig 3.12.
|
||||
|
||||
Use the ``spaceless`` filter to remove whitespace *between HTML tags*, not
|
||||
whitespace within HTML tags or whitespace in plain text:
|
||||
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
--TEMPLATE--
|
||||
{% cache 'test_%s_%s'|format(10, 10000) ttl(36000) %}
|
||||
{% set content %}
|
||||
OK
|
||||
ok
|
||||
{% endset %}
|
||||
{% apply spaceless %}
|
||||
{% apply upper %}
|
||||
{{ content }}
|
||||
{% endapply %}
|
||||
{% endcache %}
|
||||
|
||||
@@ -1,40 +1,29 @@
|
||||
--TEST--
|
||||
"inline_css" filter
|
||||
--TEMPLATE--
|
||||
{% apply inline_css|spaceless %}
|
||||
<html>
|
||||
<style>p { color: red }</style>
|
||||
<p>Great!</p>
|
||||
</html>
|
||||
{% apply inline_css %}
|
||||
<html><style>p { color: red }</style><p>Great!</p></html>
|
||||
{% endapply %}
|
||||
|
||||
|
||||
{% apply inline_css(source('css'))|spaceless %}
|
||||
<html>
|
||||
<p>Great!</p>
|
||||
</html>
|
||||
{% apply inline_css(source('css')) %}
|
||||
<html><p>Great!</p></html>
|
||||
{% endapply %}
|
||||
|
||||
|
||||
{% apply inline_css(source('css'), source('more_css'))|spaceless %}
|
||||
<html>
|
||||
<p>Great!</p>
|
||||
</html>
|
||||
{% apply inline_css(source('css'), source('more_css')) %}
|
||||
<html><p>Great!</p></html>
|
||||
{% endapply %}
|
||||
|
||||
|
||||
{% apply inline_css(source('css') ~ source('more_css'))|spaceless %}
|
||||
<html>
|
||||
<p>Great!</p>
|
||||
</html>
|
||||
{% apply inline_css(source('css') ~ source('more_css')) %}
|
||||
<html><p>Great!</p></html>
|
||||
{% endapply %}
|
||||
|
||||
|
||||
{{ include('html')|inline_css(source('css') ~ source('more_css'))|spaceless }}
|
||||
{{ include('html')|inline_css(source('css') ~ source('more_css')) }}
|
||||
--TEMPLATE(html)--
|
||||
<html>
|
||||
<p>Great!</p>
|
||||
</html>
|
||||
<html><p>Great!</p></html>
|
||||
--TEMPLATE(css)--
|
||||
p { color: red }
|
||||
--TEMPLATE(more_css)--
|
||||
@@ -42,12 +31,20 @@ p { color: blue }
|
||||
--DATA--
|
||||
return []
|
||||
--EXPECT--
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"><html><head><style>p { color: red }</style></head><body><p style="color: red;">Great!</p></body></html>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head><style>p { color: red }</style></head>
|
||||
<body><p style="color: red;">Great!</p></body>
|
||||
</html>
|
||||
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"><html><body><p style="color: red;">Great!</p></body></html>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html><body><p style="color: red;">Great!</p></body></html>
|
||||
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"><html><body><p style="color: blue;">Great!</p></body></html>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html><body><p style="color: blue;">Great!</p></body></html>
|
||||
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"><html><body><p style="color: blue;">Great!</p></body></html>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html><body><p style="color: blue;">Great!</p></body></html>
|
||||
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"><html><body><p style="color: blue;">Great!</p></body></html>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html><body><p style="color: blue;">Great!</p></body></html>
|
||||
|
||||
@@ -220,6 +220,7 @@ final class CoreExtension extends AbstractExtension
|
||||
new TwigFilter('trim', self::trim(...)),
|
||||
new TwigFilter('nl2br', self::nl2br(...), ['pre_escape' => 'html', 'is_safe' => ['html']]),
|
||||
new TwigFilter('spaceless', self::spaceless(...), ['is_safe' => ['html']]),
|
||||
new TwigFilter('spaceless', self::spaceless(...), ['is_safe' => ['html'], 'deprecated' => '3.12', 'deprecating_package' => 'twig/twig']),
|
||||
|
||||
// array helpers
|
||||
new TwigFilter('join', self::join(...)),
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
--TEST--
|
||||
"spaceless" filter
|
||||
--DEPRECATION--
|
||||
Since twig/twig 3.12: Twig Filter "spaceless" is deprecated in index.twig at line 2.
|
||||
Since twig/twig 3.12: Twig Filter "spaceless" is deprecated in index.twig at line 3.
|
||||
Since twig/twig 3.12: Twig Filter "spaceless" is deprecated in index.twig at line 4.
|
||||
--TEMPLATE--
|
||||
{{ " <div> <div> foo </div> </div>"|spaceless }}
|
||||
*{{ ""|spaceless }}*
|
||||
*{{ null|spaceless }}*
|
||||
--DATA--
|
||||
return []
|
||||
--EXPECT--
|
||||
<div><div> foo </div></div>
|
||||
**
|
||||
**
|
||||
@@ -1,12 +0,0 @@
|
||||
--TEST--
|
||||
"spaceless" filter
|
||||
--TEMPLATE--
|
||||
{{ " <div> <div> foo </div> </div>"|spaceless }}
|
||||
*{{ ""|spaceless }}*
|
||||
*{{ null|spaceless }}*
|
||||
--DATA--
|
||||
return []
|
||||
--EXPECT--
|
||||
<div><div> foo </div></div>
|
||||
**
|
||||
**
|
||||
@@ -4,11 +4,11 @@ macro
|
||||
{{ _self.some_macro() }}
|
||||
|
||||
{% macro some_macro() %}
|
||||
{% apply spaceless %}
|
||||
{% apply upper %}
|
||||
{% if true %}foo{% endif %}
|
||||
{% endapply %}
|
||||
{% endmacro %}
|
||||
--DATA--
|
||||
return []
|
||||
--EXPECT--
|
||||
foo
|
||||
FOO
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"apply" tag does not create a new scope
|
||||
--TEMPLATE--
|
||||
{% set foo = 'baz' %}
|
||||
{% apply spaceless %}
|
||||
{% apply upper %}
|
||||
{% set foo = 'foo' %}
|
||||
{% set bar = 'bar' %}
|
||||
{% endapply %}
|
||||
|
||||
Reference in New Issue
Block a user