TYPO3 / Fluid

Fluid template rendering engine - Standalone version
GNU Lesser General Public License v3.0
152 stars 93 forks source link

Not possible to use wrapper-sections in Layout(s) #280

Open InvisibleKind opened 7 years ago

InvisibleKind commented 7 years ago

Hi,

I wanted to utilize the feature, which makes it possible to use sections as wrappers.

Here is my Layouts/Default.html:

<f:render section="ContentWrap" contentAs="contentVariable">
    <b>hello</b>
</f:render>

Templates/Main.html

<f:section name="ContentWrap">
    <div class="my-class">
        {contentVariable}
    </div>
</f:section>

But {contentVariable} is always null. After some debugging I found the troublemaker: \TYPO3Fluid\Fluid\View\AbstractTemplateView and exactly this part:

if ($this->getCurrentRenderingType() === self::RENDERING_LAYOUT) {
    // in case we render a layout right now, we will render a section inside a TEMPLATE.
    $renderingTypeOnNextLevel = self::RENDERING_TEMPLATE;
} else {
    $renderingContext = clone $renderingContext;
    $renderingContext->setVariableProvider($renderingContext->getVariableProvider()->getScopeCopy($variables));
    $renderingTypeOnNextLevel = $this->getCurrentRenderingType();
}

So, no variables are passed in case of rendering section inside of layout. If I simply add $renderingContext->setVariableProvider($renderingContext->getVariableProvider()->getScopeCopy($variables)); in if-section, everything works as expected.

The question: is it bug or made for purpose so?

s2b commented 11 months ago

469