Skip to content

Support <f:section> inside of the component template #91

@rosty-matviiv

Description

@rosty-matviiv

It was discovered that if you have <f:section> defined inside of your component then <f:render section=""> will throw the error that such section is not found (or is not defined)

Code Example

MediaGallery.html - just regular fluid template

<html>
    <sfc:molecule.media
        records="{records}"
    />
</html>

Components/Molecule/Media/Media.html

<fc:component>
    <fc:param name="records" type="array" description="Gallery Records"/>

    <fc:renderer>
        <f:for each="{records}" as="record">
            <f:render section="SomeSection" arguments="{record:record}"></f:render>
        </f:for>

        <f:section name="SomeSection">
            Hello World - {record.title}
        </f:section>
    </fc:renderer>
</fc:component>

Would be good to have it working some day :)

I debugged it a bit and discovered that if you would define <f:section> inside of the original fluid template (MediaGallery.html) then it would work.

Just would like to keep this issue here for future as a help for others

Workaround 1

In case if you are using sections just to avoid code duplications then you can use <f:variable> instead of the section

Workaround 2

However, if you are rendering some section inside of the loop (like on the code examples above) and you have some variable which exists or contain unique value only in one cycle of the loop (in our case it is {record}) then usage of <f:variable> is not possible or at least too complicated.
In this scenario we just created one more component (atom for example) which was responsible to render that part of the code which was supposed to be inside of the section. So another component was used instead of the section. Looks almost the same and works the same.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions