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); }