From 0a9f3b75a9195092ff7c42265ec066339d8f8aa3 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Tue, 19 Mar 2013 11:43:23 +0100 Subject: [PATCH] Fixed deprecated usage of <% control %> --- forms/CompositeField.php | 2 +- forms/Form.php | 2 +- tests/view/SSViewerCacheBlockTest.php | 6 ++--- tests/view/SSViewerTest.php | 34 +++++++++++++-------------- view/SSTemplateParser.php | 2 +- 5 files changed, 23 insertions(+), 23 deletions(-) diff --git a/forms/CompositeField.php b/forms/CompositeField.php index 23e66a20d..f47d3aa2e 100644 --- a/forms/CompositeField.php +++ b/forms/CompositeField.php @@ -61,7 +61,7 @@ class CompositeField extends FormField { } /** - * Returns all the sub-fields, suitable for <% control FieldList %> + * Returns all the sub-fields, suitable for <% loop FieldList %> * * @return FieldList */ diff --git a/forms/Form.php b/forms/Form.php index 56e05d86b..10038e92e 100644 --- a/forms/Form.php +++ b/forms/Form.php @@ -1227,7 +1227,7 @@ class Form extends RequestHandler { * Return a rendered version of this form. * * This is returned when you access a form as $FormObject rather - * than <% control FormObject %> + * than <% with FormObject %> */ public function forTemplate() { $return = $this->renderWith(array_merge( diff --git a/tests/view/SSViewerCacheBlockTest.php b/tests/view/SSViewerCacheBlockTest.php index 7350da29e..0f81a099e 100644 --- a/tests/view/SSViewerCacheBlockTest.php +++ b/tests/view/SSViewerCacheBlockTest.php @@ -206,7 +206,7 @@ class SSViewerCacheBlockTest extends SapphireTest { public function testNoErrorMessageForControlWithinCached() { $this->_reset(true); - $this->assertNotNull($this->_runtemplate('<% cached %><% control Foo %>$Bar<% end_control %><% end_cached %>')); + $this->assertNotNull($this->_runtemplate('<% cached %><% with Foo %>$Bar<% end_with %><% end_cached %>')); } /** @@ -215,13 +215,13 @@ class SSViewerCacheBlockTest extends SapphireTest { public function testErrorMessageForCachedWithinControlWithinCached() { $this->_reset(true); $this->_runtemplate( - '<% cached %><% control Foo %><% cached %>$Bar<% end_cached %><% end_control %><% end_cached %>'); + '<% cached %><% with Foo %><% cached %>$Bar<% end_cached %><% end_with %><% end_cached %>'); } public function testNoErrorMessageForCachedWithinControlWithinUncached() { $this->_reset(true); $this->assertNotNull($this->_runtemplate( - '<% uncached %><% control Foo %><% cached %>$Bar<% end_cached %><% end_control %><% end_uncached %>')); + '<% uncached %><% with Foo %><% cached %>$Bar<% end_cached %><% end_with %><% end_uncached %>')); } /** diff --git a/tests/view/SSViewerTest.php b/tests/view/SSViewerTest.php index 01d789a26..f3f10f555 100644 --- a/tests/view/SSViewerTest.php +++ b/tests/view/SSViewerTest.php @@ -275,12 +275,12 @@ SS; ); } - public function testControlWhitespace() { + public function testLoopWhitespace() { $this->assertEquals( 'before[out:SingleItem.Test]after beforeTestafter', - $this->render('before<% control SingleItem %>$Test<% end_control %>after - before<% control SingleItem %>Test<% end_control %>after') + $this->render('before<% loop SingleItem %>$Test<% end_loop %>after + before<% loop SingleItem %>Test<% end_loop %>after') ); // The control tags are removed from the output, but no whitespace @@ -293,9 +293,9 @@ SS; after', $this->render('before -<% control SingleItem %> +<% loop SingleItem %> $ItemOnItsOwnLine -<% end_control %> +<% end_loop %> after') ); @@ -313,9 +313,9 @@ after') after', $this->render('before -<% control Loop3 %> +<% loop Loop3 %> $ItemOnItsOwnLine -<% end_control %> +<% end_loop %> after') ); } @@ -328,28 +328,28 @@ after') [out:Foo(Arg1).Item] [out:Foo(Arg1,Arg2).Item] [out:Foo(Arg1,Arg2,Arg3).Item]', - $this->render('<% control Foo.Bar %>a{$Item}b<% end_control %> - <% control Foo.Bar(Arg1) %>$Item<% end_control %> - <% control Foo(Arg1) %>$Item<% end_control %> - <% control Foo(Arg1, Arg2) %>$Item<% end_control %> - <% control Foo(Arg1, Arg2, Arg3) %>$Item<% end_control %>') + $this->render('<% with Foo.Bar %>a{$Item}b<% end_with %> + <% with Foo.Bar(Arg1) %>$Item<% end_with %> + <% with Foo(Arg1) %>$Item<% end_with %> + <% with Foo(Arg1, Arg2) %>$Item<% end_with %> + <% with Foo(Arg1, Arg2, Arg3) %>$Item<% end_with %>') ); // Loop controls $this->assertEquals('a[out:Foo.Loop2.Item]ba[out:Foo.Loop2.Item]b', - $this->render('<% control Foo.Loop2 %>a{$Item}b<% end_control %>')); + $this->render('<% loop Foo.Loop2 %>a{$Item}b<% end_loop %>')); $this->assertEquals('[out:Foo.Loop2(Arg1).Item][out:Foo.Loop2(Arg1).Item]', - $this->render('<% control Foo.Loop2(Arg1) %>$Item<% end_control %>')); + $this->render('<% loop Foo.Loop2(Arg1) %>$Item<% end_loop %>')); $this->assertEquals('[out:Loop2(Arg1).Item][out:Loop2(Arg1).Item]', - $this->render('<% control Loop2(Arg1) %>$Item<% end_control %>')); + $this->render('<% loop Loop2(Arg1) %>$Item<% end_loop %>')); $this->assertEquals('[out:Loop2(Arg1,Arg2).Item][out:Loop2(Arg1,Arg2).Item]', - $this->render('<% control Loop2(Arg1, Arg2) %>$Item<% end_control %>')); + $this->render('<% loop Loop2(Arg1, Arg2) %>$Item<% end_loop %>')); $this->assertEquals('[out:Loop2(Arg1,Arg2,Arg3).Item][out:Loop2(Arg1,Arg2,Arg3).Item]', - $this->render('<% control Loop2(Arg1, Arg2, Arg3) %>$Item<% end_control %>')); + $this->render('<% loop Loop2(Arg1, Arg2, Arg3) %>$Item<% end_loop %>')); } diff --git a/view/SSTemplateParser.php b/view/SSTemplateParser.php index d2f16a90e..912f1f35d 100644 --- a/view/SSTemplateParser.php +++ b/view/SSTemplateParser.php @@ -3544,7 +3544,7 @@ class SSTemplateParser extends Parser { * @deprecated */ function ClosedBlock_Handle_Control(&$res) { - Deprecation::notice('3.1', 'Use <% with %> or <% loop %> instead.'); + Deprecation::notice('3.1', '<% control %> is deprecated. Use <% with %> or <% loop %> instead.'); return $this->ClosedBlock_Handle_Loop($res); }