Index: Classes/Core/ViewHelper/TagBasedViewHelper.php =================================================================== --- Classes/Core/ViewHelper/TagBasedViewHelper.php (revision 2913) +++ Classes/Core/ViewHelper/TagBasedViewHelper.php (working copy) @@ -87,6 +87,8 @@ */ public function initialize() { parent::initialize(); + $this->tag->removeAllAttributes(); + $this->tag->setContent(NULL); $this->tag->setTagName($this->tagName); if (is_array($this->arguments['additionalAttributes'])) { $this->tag->addAttributes($this->arguments['additionalAttributes']); Index: Classes/Core/ViewHelper/TagBuilder.php =================================================================== --- Classes/Core/ViewHelper/TagBuilder.php (revision 2914) +++ Classes/Core/ViewHelper/TagBuilder.php (working copy) @@ -191,6 +191,17 @@ } /** + * Removes all attribute from the $attributes-collection + * + * @return void + * @author Bastian Waidelich + * @api + */ + public function removeAllAttributes() { + $this->attributes = array(); + } + + /** * Renders and returns the tag * * @return void Index: Tests/Core/TagBasedViewHelperTest.php =================================================================== --- Tests/Core/TagBasedViewHelperTest.php (revision 2914) +++ Tests/Core/TagBasedViewHelperTest.php (working copy) @@ -28,8 +28,22 @@ public function setUp() { $this->viewHelper = new \F3\Fluid\Core\Fixtures\TestTagBasedViewHelper(); } + /** * @test + * @author Bastian Waidelich + */ + public function initializeRemovesAttributesAndContentsOfUnderlyingTagBuilder() { + $mockTagBuilder = $this->getMock('F3\Fluid\Core\ViewHelper\TagBuilder', array('removeAllAttributes', 'setContent'), array(), '', FALSE); + $mockTagBuilder->expects($this->once())->method('removeAllAttributes'); + $mockTagBuilder->expects($this->once())->method('setContent')->with(NULL); + $this->viewHelper->injectTagBuilder($mockTagBuilder); + + $this->viewHelper->initialize(); + } + + /** + * @test * @author Sebastian Kurfürst * @author Bastian Waidelich */ Index: Tests/Core/TagBuilderTest.php =================================================================== --- Tests/Core/TagBuilderTest.php (revision 2913) +++ Tests/Core/TagBuilderTest.php (working copy) @@ -102,6 +102,16 @@ * @test * @author Bastian Waidelich */ + public function contentCanBeRemoved() { + $tagBuilder = new \F3\Fluid\Core\ViewHelper\TagBuilder('tag', 'some content'); + $tagBuilder->setContent(NULL); + $this->assertEquals('', $tagBuilder->render()); + } + + /** + * @test + * @author Bastian Waidelich + */ public function renderReturnsOpeningAndClosingTagIfNoContentIsSpecifiedButForceClosingTagIsTrue() { $tagBuilder = new \F3\Fluid\Core\ViewHelper\TagBuilder('tag'); $tagBuilder->forceClosingTag(TRUE); @@ -157,6 +167,18 @@ * @test * @author Bastian Waidelich */ + public function removeAllAttributesRemovesAllAttributes() { + $tagBuilder = new \F3\Fluid\Core\ViewHelper\TagBuilder('tagName', 'tag content'); + $tagBuilder->addAttribute('attribute1', 'attribute1value'); + $tagBuilder->addAttribute('attribute2', 'attribute2value'); + $tagBuilder->removeAllAttributes(); + $this->assertEquals('tag content', $tagBuilder->render()); + } + + /** + * @test + * @author Bastian Waidelich + */ public function tagNameCanBeOverridden() { $tagBuilder = new \F3\Fluid\Core\ViewHelper\TagBuilder('foo'); $tagBuilder->setTagName('bar');