Skip to content

Commit

Permalink
Merge pull request #3202 from jonnitto/feature/replace_fusion_collection
Browse files Browse the repository at this point in the history
FEATURE: Replace Fusion:Collection with Fusion:Loop
  • Loading branch information
bwaidelich authored Nov 25, 2020
2 parents a3b374f + 7677285 commit 6ca2ece
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 33 deletions.
8 changes: 4 additions & 4 deletions Neos.Fusion/Tests/Functional/FusionObjects/ApplyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,20 +220,20 @@ public function nestedPrototypeOverriddenWithSpreadsRendering()
/**
* @test
*/
public function collectionWithoutSpreadRendering()
public function loopWithoutSpreadRendering()
{
$view = $this->buildView();
$view->setFusionPath('apply/renderCollectionWithoutSpread');
$view->setFusionPath('apply/renderLoopWithoutSpread');
self::assertEquals('X1X2X2X3', $view->render());
}

/**
* @test
*/
public function collectionWithSpreadRendering()
public function loopWithSpreadRendering()
{
$view = $this->buildView();
$view->setFusionPath('apply/renderCollectionWithSpread');
$view->setFusionPath('apply/renderLoopWithSpread');
self::assertEquals('X1X2X2X3', $view->render());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function exceptionalEelExpressionInOverrideIsHandledCorrectly()
$view->setFusionPath('exceptionHandler/eelExpressionInOverride');
$output = $view->render();
self::assertStringStartsWith('StartException while rendering exceptionHandler', $output);
self::assertStringContainsString('myCollection', $output, 'The override path should be visible in the message Fusion path');
self::assertStringContainsString('myItems', $output, 'The override path should be visible in the message Fusion path');
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
prototype(Neos.Fusion:TestRenderer).@class = 'Neos\\Fusion\\Tests\\Functional\\View\\Fixtures\\TestRenderer'
prototype(Neos.Fusion:Value).@class = 'Neos\\Fusion\\FusionObjects\\ValueImplementation'
prototype(Neos.Fusion:Collection).@class = 'Neos\\Fusion\\FusionObjects\\CollectionImplementation'
prototype(Neos.Fusion:Loop).@class = 'Neos\\Fusion\\FusionObjects\\LoopImplementation'
prototype(Neos.Fusion:DataStructure).@class = 'Neos\\Fusion\\FusionObjects\\DataStructureImplementation'
prototype(Neos.Fusion:Join).@class = 'Neos\\Fusion\\FusionObjects\\JoinImplementation'
prototype(Neos.Fusion:Renderer).@class = 'Neos\\Fusion\\FusionObjects\\RendererImplementation'
Expand Down Expand Up @@ -106,16 +106,16 @@ apply.renderNestedPrototypeOverriddenWithSpreads = Neos.Fusion:NestedPrototype {
@apply.alterValue = ${{value: 'i can change this'}}
}

apply.renderCollectionWithoutSpread = Neos.Fusion:Collection {
collection = ${[{test:1},{test:2},{test:2},{test:3}]}
apply.renderLoopWithoutSpread = Neos.Fusion:Loop {
items = ${[{test:1},{test:2},{test:2},{test:3}]}
itemName = 'item'
itemRenderer = Neos.Fusion:TestRenderer {
test = ${item.test}
}
}

apply.renderCollectionWithSpread = Neos.Fusion:Collection {
collection = ${[{test:1},{test:2},{test:2},{test:3}]}
apply.renderLoopWithSpread = Neos.Fusion:Loop {
items = ${[{test:1},{test:2},{test:2},{test:3}]}
itemName = 'item'
itemRenderer = Neos.Fusion:TestRenderer {
@apply.applyItem = ${item}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,8 @@ contentCache.nestedCacheSegmentsWithInnerException = Neos.Fusion:Join {

10 = ${'counter=' + object.counter + '|'}

15 = Neos.Fusion:Collection {
collection = ${['Foo', 'Bar']}
15 = Neos.Fusion:Loop {
items = ${['Foo', 'Bar']}
itemName = 'item'
itemRenderer = Neos.Fusion:Template {
templatePath = 'no.such.file.here.so.crash.please'
Expand Down Expand Up @@ -346,8 +346,8 @@ contentCache.nestedCacheSegmentsWithConditionalException = Neos.Fusion:Join {
}

// Use an exception to have the exception handler working
20 = Neos.Fusion:Collection {
collection = ${['Foo']}
20 = Neos.Fusion:Loop {
items = ${['Foo']}

itemName = 'item'
itemRenderer = Neos.Fusion:Testing.Throwing {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ prototype(Neos.Fusion:Testing.Throwing).@class = 'Neos\\Fusion\\Tests\\Functiona

exceptionHandler.eelExpressionInProperty = Neos.Fusion:Join {
start = 'Start'
error = Neos.Fusion:Collection {
collection = ${Testing.Utility.throwException()}
error = Neos.Fusion:Loop {
items = ${Testing.Utility.throwException()}

@exceptionHandler = 'Neos\\Fusion\\Core\\ExceptionHandlers\\PlainTextHandler'
}
Expand All @@ -12,9 +12,9 @@ exceptionHandler.eelExpressionInProperty = Neos.Fusion:Join {

exceptionHandler.eelExpressionInOverride = Neos.Fusion:Join {
start = 'Start'
error = Neos.Fusion:Collection {
@context.myCollection = ${Testing.Utility.throwException()}
collection = ${myCollection}
error = Neos.Fusion:Loop {
@context.myItems = ${Testing.Utility.throwException()}
items = ${myItems}
itemName = 'item'

@exceptionHandler = 'Neos\\Fusion\\Core\\ExceptionHandlers\\PlainTextHandler'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ template.layout = Neos.Fusion:Template {
}

# This fixture sets up a Fusion object that will throw an exception during rendering
# (a Collection needs an itemName property to be set)
# (a Loop needs an itemName property to be set)
template.offsetAccessException = Neos.Fusion:Template {
templatePath = ${fixtureDirectory + 'Templates/BasicTemplate.html'}

myVariable = Neos.Fusion:Collection {
collection = ${['foo', 'bar']}
myVariable = Neos.Fusion:Loop {
items = ${['foo', 'bar']}
@exceptionHandler = 'Neos\\Fusion\\Core\\ExceptionHandlers\\PlainTextHandler'
}
}
Expand Down
10 changes: 5 additions & 5 deletions Neos.Fusion/Tests/Functional/FusionObjects/LoopTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class LoopTest extends AbstractFusionObjectTest
/**
* @test
*/
public function basicCollectionWorks()
public function basicLoopWorks()
{
$view = $this->buildView();
$view->assign('items', ['element1', 'element2']);
Expand All @@ -31,7 +31,7 @@ public function basicCollectionWorks()
/**
* @test
*/
public function basicCollectionWorksWithGlue()
public function basicLoopWorksWithGlue()
{
$view = $this->buildView();
$view->assign('items', ['element1', 'element2']);
Expand All @@ -42,7 +42,7 @@ public function basicCollectionWorksWithGlue()
/**
* @test
*/
public function basicCollectionWorksAndStillContainsOtherContextVariables()
public function basicLoopWorksAndStillContainsOtherContextVariables()
{
$view = $this->buildView();
$view->assign('items', ['element1', 'element2']);
Expand All @@ -54,7 +54,7 @@ public function basicCollectionWorksAndStillContainsOtherContextVariables()
/**
* @test
*/
public function emptyCollectionReturnsEmptyString()
public function emptyLoopReturnsEmptyString()
{
$view = $this->buildView();
$view->assign('items', null);
Expand All @@ -65,7 +65,7 @@ public function emptyCollectionReturnsEmptyString()
/**
* @test
*/
public function iterationInformationIsAddedToCollection()
public function iterationInformationIsAddedToLoop()
{
$view = $this->buildView();
$view->assign('items', ['element1', 'element2', 'element3', 'element4']);
Expand Down
4 changes: 2 additions & 2 deletions Neos.Neos/Resources/Private/Fusion/RawContentMode.fusion
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
prototype(Neos.Neos:RawContent) >
prototype(Neos.Neos:RawContent) < prototype(Neos.Fusion:Template) {
templatePath = 'resource://Neos.Neos/Private/Templates/RawContentMode/FusionObjects/GeneralContentCollectionRendering.html'
columns = Neos.Fusion:Collection {
collection = ${q(node).children('[instanceof Neos.Neos:ContentCollection]')}
columns = Neos.Fusion:Loop {
items = ${q(node).children('[instanceof Neos.Neos:ContentCollection]')}
itemName = 'node'
itemRenderer = Neos.Fusion:Template {
templatePath = 'resource://Neos.Neos/Private/Templates/RawContentMode/FusionObjects/ContentCollectionTemplate.html'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ prototype(Neos.NodeTypes.ColumnLayouts:MultiColumn) < prototype(Neos.Neos:Conten
templatePath = 'resource://Neos.NodeTypes.ColumnLayouts/Private/Templates/NodeTypes/MultiColumn.html'
layout = ${q(node).property('layout')}
attributes.class = ${'container columns-' + q(node).property('layout')}
columns = Neos.Fusion:Collection {
columns = Neos.Fusion:Loop {
@context.columnLayout = ${q(node).property('layout')}
collection = ${q(node).children('[instanceof Neos.Neos:ContentCollection]')}
items = ${q(node).children('[instanceof Neos.Neos:ContentCollection]')}
itemRenderer = Neos.NodeTypes.ColumnLayouts:MultiColumnItem
itemName = 'node'
iterationName = 'columnIteration'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
prototype(Neos.NodeTypes.ContentReferences:ContentReferences) < prototype(Neos.Neos:Content) {
templatePath = 'resource://Neos.NodeTypes.ContentReferences/Private/Templates/NodeTypes/ContentReferences.html'
@context.referenceNodesArray = ${q(node).property('references')}
referenceNodes = Neos.Fusion:Collection {
collection = ${referenceNodesArray}
referenceNodes = Neos.Fusion:Loop {
items = ${referenceNodesArray}
itemRenderer = Neos.Neos:ContentCase
itemName = 'node'
}
Expand Down

0 comments on commit 6ca2ece

Please sign in to comment.