Fixed deprecated usage of <% control %>

This commit is contained in:
Ingo Schommer 2013-03-19 11:43:23 +01:00
parent b8a51c3792
commit 0a9f3b75a9
5 changed files with 23 additions and 23 deletions

View File

@ -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
*/

View File

@ -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(

View File

@ -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 %>'));
}
/**

View File

@ -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 %>'));
}

View File

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