mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
Fixed deprecated usage of <% control %>
This commit is contained in:
parent
b8a51c3792
commit
0a9f3b75a9
@ -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
|
* @return FieldList
|
||||||
*/
|
*/
|
||||||
|
@ -1227,7 +1227,7 @@ class Form extends RequestHandler {
|
|||||||
* Return a rendered version of this form.
|
* Return a rendered version of this form.
|
||||||
*
|
*
|
||||||
* This is returned when you access a form as $FormObject rather
|
* This is returned when you access a form as $FormObject rather
|
||||||
* than <% control FormObject %>
|
* than <% with FormObject %>
|
||||||
*/
|
*/
|
||||||
public function forTemplate() {
|
public function forTemplate() {
|
||||||
$return = $this->renderWith(array_merge(
|
$return = $this->renderWith(array_merge(
|
||||||
|
@ -206,7 +206,7 @@ class SSViewerCacheBlockTest extends SapphireTest {
|
|||||||
|
|
||||||
public function testNoErrorMessageForControlWithinCached() {
|
public function testNoErrorMessageForControlWithinCached() {
|
||||||
$this->_reset(true);
|
$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() {
|
public function testErrorMessageForCachedWithinControlWithinCached() {
|
||||||
$this->_reset(true);
|
$this->_reset(true);
|
||||||
$this->_runtemplate(
|
$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() {
|
public function testNoErrorMessageForCachedWithinControlWithinUncached() {
|
||||||
$this->_reset(true);
|
$this->_reset(true);
|
||||||
$this->assertNotNull($this->_runtemplate(
|
$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 %>'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -275,12 +275,12 @@ SS;
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testControlWhitespace() {
|
public function testLoopWhitespace() {
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
'before[out:SingleItem.Test]after
|
'before[out:SingleItem.Test]after
|
||||||
beforeTestafter',
|
beforeTestafter',
|
||||||
$this->render('before<% control SingleItem %>$Test<% end_control %>after
|
$this->render('before<% loop SingleItem %>$Test<% end_loop %>after
|
||||||
before<% control SingleItem %>Test<% end_control %>after')
|
before<% loop SingleItem %>Test<% end_loop %>after')
|
||||||
);
|
);
|
||||||
|
|
||||||
// The control tags are removed from the output, but no whitespace
|
// The control tags are removed from the output, but no whitespace
|
||||||
@ -293,9 +293,9 @@ SS;
|
|||||||
|
|
||||||
after',
|
after',
|
||||||
$this->render('before
|
$this->render('before
|
||||||
<% control SingleItem %>
|
<% loop SingleItem %>
|
||||||
$ItemOnItsOwnLine
|
$ItemOnItsOwnLine
|
||||||
<% end_control %>
|
<% end_loop %>
|
||||||
after')
|
after')
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -313,9 +313,9 @@ after')
|
|||||||
|
|
||||||
after',
|
after',
|
||||||
$this->render('before
|
$this->render('before
|
||||||
<% control Loop3 %>
|
<% loop Loop3 %>
|
||||||
$ItemOnItsOwnLine
|
$ItemOnItsOwnLine
|
||||||
<% end_control %>
|
<% end_loop %>
|
||||||
after')
|
after')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -328,28 +328,28 @@ after')
|
|||||||
[out:Foo(Arg1).Item]
|
[out:Foo(Arg1).Item]
|
||||||
[out:Foo(Arg1,Arg2).Item]
|
[out:Foo(Arg1,Arg2).Item]
|
||||||
[out:Foo(Arg1,Arg2,Arg3).Item]',
|
[out:Foo(Arg1,Arg2,Arg3).Item]',
|
||||||
$this->render('<% control Foo.Bar %>a{$Item}b<% end_control %>
|
$this->render('<% with Foo.Bar %>a{$Item}b<% end_with %>
|
||||||
<% control Foo.Bar(Arg1) %>$Item<% end_control %>
|
<% with Foo.Bar(Arg1) %>$Item<% end_with %>
|
||||||
<% control Foo(Arg1) %>$Item<% end_control %>
|
<% with Foo(Arg1) %>$Item<% end_with %>
|
||||||
<% control Foo(Arg1, Arg2) %>$Item<% end_control %>
|
<% with Foo(Arg1, Arg2) %>$Item<% end_with %>
|
||||||
<% control Foo(Arg1, Arg2, Arg3) %>$Item<% end_control %>')
|
<% with Foo(Arg1, Arg2, Arg3) %>$Item<% end_with %>')
|
||||||
);
|
);
|
||||||
|
|
||||||
// Loop controls
|
// Loop controls
|
||||||
$this->assertEquals('a[out:Foo.Loop2.Item]ba[out:Foo.Loop2.Item]b',
|
$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->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->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->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->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 %>'));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3544,7 +3544,7 @@ class SSTemplateParser extends Parser {
|
|||||||
* @deprecated
|
* @deprecated
|
||||||
*/
|
*/
|
||||||
function ClosedBlock_Handle_Control(&$res) {
|
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);
|
return $this->ClosedBlock_Handle_Loop($res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user