Closed GuySartorelli closed 1 month ago
Found while working on https://github.com/silverstripe/silverstripe-framework/issues/11237
If you create a <% loop %> tag inside a template without including an argument (i.e. not <% loop $MyIterable %>), the template is generated with some very clearly incomplete code, which includes the placeholder "Foo".
<% loop %>
<% loop $MyIterable %>
Template:
<% loop %> // Inside the loop here <% end_loop %>
Cached template (what actually gets executed):
$scope->obj('Up', null)->obj('Foo', null); $scope->pushScope(); while (($key = $scope->next()) !== false) { $val .= ' // Inside the loop here'; }; $scope->popScope();
This is handled by SSTemplateParser::ClosedBlock_Handle_Loop()
SSTemplateParser::ClosedBlock_Handle_Loop()
The relevant code was added in https://github.com/silverstripe/silverstripe-framework/commit/91f4ba15f15970638da5091639e35daae17f3c6f as part of https://github.com/silverstripe/silverstripe-framework/pull/209 and it seems pretty clear the intention was to loop over whatever is currently in scope (basically a shortcut for <% loop $Me %>) but that for whatever reason the feature was never fully implemented.
<% loop $Me %>
PRs merged. Task is completed. Close.
Found while working on https://github.com/silverstripe/silverstripe-framework/issues/11237
If you create a
<% loop %>
tag inside a template without including an argument (i.e. not<% loop $MyIterable %>
), the template is generated with some very clearly incomplete code, which includes the placeholder "Foo".Template:
Cached template (what actually gets executed):
This is handled by
SSTemplateParser::ClosedBlock_Handle_Loop()
The relevant code was added in https://github.com/silverstripe/silverstripe-framework/commit/91f4ba15f15970638da5091639e35daae17f3c6f as part of https://github.com/silverstripe/silverstripe-framework/pull/209 and it seems pretty clear the intention was to loop over whatever is currently in scope (basically a shortcut for
<% loop $Me %>
) but that for whatever reason the feature was never fully implemented.PRs