Creating function block in volt

I would like to have a function block that I can assign the content within the block to a variable, but I can find a way to do so. I have used macros but the problem I that I cant return html content within the block. Below is what I intend to achieve:

{%- capture variableName %}
    <section>
        {% for row in rows %}
        <div>
            name: {{ row.name }}
        </div>
        {% endfor %}
    </section>
{%- endcapture %}

so I call within the template where I have the above block or a template within its scope

{% capture variableName %}

the content in the block should be assigned to variableName. How can I go about achieving this?

Maybe use partial/include ?



689

partial/include wont fit for a solution. as I would like to pass the content from the function as a parameter for partial

Why they dont fit ? you can pass parameter to include/partial too.



689

I am aware that I can pass parameters to include/partial. The thing is I have a view (having sections for side menu & content as vairables) which I would like to reuse with specific actions, this view extend a base layout and would be extended by the Level_Layout. I wanted to in the level layout have in two function block the content for the extended view. Since it's not possible to have nexted {block}. In summary, What I'm trying to achieve with a function block is similar to smarty {content assign='varaiableName'}{/content}