Closed carloszimm closed 1 year ago
@carloszimm great question!
A partial is a reusable component that you can include multiple places. Think of a button or navbar.
A layout is a template that's automatically applied to the "outside" of your current template. It's nice if you want to wrap multiple templates in the same common elements. For example, I could have two files ("about.eta" and "index.eta") that both use the "layout.eta" template. The "layout.eta" template would wrap the two files in html
, main
, and body
tags and add links to scripts and CSS files.
@nebrelbug nice! I think I got it :)
About the data in the it
variable, is it only populated with the body
field or it has access to all data in scope? For instance, in EJS (ETA as well), partials have access to the parent view (or you could pass the data through the include
). Or is layout
something a little more static?
The layout
will have access to the body
field, but also the rest of it
:)
Alright! Now I see its full advantage (write less repetitive template/partial parts) :D Closing the issue/question...
Hi! From the docs, I couldn't grasp the idea behind having those two features :( I understand that partials are meant to be reusable components. Is layout the same? It's a better way to organize the "layout" in page/view? What's the advantages over EJS (why this is a compelling feature)? What's the data scope between template and layout? I think a complete example with the main features would clarify a little bit (I couldn't find any under 'Resources/Tutorials and Articles'. Any enlightenment is welcome :)