jasonprogrammer / tagg

An HTML templating library written in Gleam, that uses XML/HTML tag syntax
MIT License
19 stars 0 forks source link

Layouts/slot support #1

Open AdamBrodzinski opened 2 weeks ago

AdamBrodzinski commented 2 weeks ago

Thanks so much for making this lovely library! I was wondering if there were any plans on supporting a layout or "slot" to allow passing data into a component? for example:

<component path="layouts/main_layout.html">
  <h1>Hello world</h1>
</component>
jasonprogrammer commented 2 weeks ago

Thanks for the kind words! So far I hadn't planned on adding slots, but it's certainly possible to do and it could be useful to have. I'm imagining there'd need to be some sort of <slot> or something in the main_layout.html, to indicate where the child content (the <h1> in the example above) would be inserted.

AdamBrodzinski commented 1 week ago

Thanks for considering the feature :tada: . Currently i'm working around this by making two components where the head and opening body tag are in one component and the footer+closing body tag in the second component like this. It actually works pretty well! I thought i'd leave this here in case anyone else runs into this as a blocker.

<component path="components/layouts/main_layout_start.html" />
  <h1>Hello World!</h1>
  <p>Testing 123</p>
<component path="components/layouts/main_layout_end.html" />