Skip to content

Template composition with child elements #113

Open
@DrSloth

Description

Hi,
it would be nice if sailfish could be used to build reusable parent containers that are completely independent of their child html. This would require a new token to start a block which accepts child elements, a new token to end the block of child elements and a new token to actually insert the children. In my examples i'm just going to use [ for start of "child block" ] for end of child block and ^ for insert children here (these tokens might be problematic, but that's mainly bikeshedding)

Something along the lines of:
In the file main.stpl:

<%[ TemplateWithChildren::new("Bye") %>
    <p> Hello World! </p> 
<%] %>

In the file template_with_children.stpl which is used to render TemplateWithChildren:

<div>
     <%^%>
     <p> <%= field_of_struct %> </p>
</div>

This would then render:

<div>
     <p> Hello World! </p>
     <p> Bye </p>
</div>

is there interest for this feature? This seems as something very useful to make sailfish a lot more flexible. If there is interest for this i would be willing to try implementing this. There are obviously some questions left on how this should be implemented, but i already have some ideas for this.

Thanks :)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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