Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Template composition with child elements #113

Open
DrSloth opened this issue Mar 13, 2023 · 0 comments
Open

Template composition with child elements #113

DrSloth opened this issue Mar 13, 2023 · 0 comments

Comments

@DrSloth
Copy link

DrSloth commented Mar 13, 2023

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 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant