Since Layout templates are so handy (cutting the template into interchangeable header/sidebar/footer, etc), why should our use an embed tag? Any ideas on when you should not use an embed tag over a layout tag?
1 Answer
One simple difference is that you can use only 1 layout template to do what takes at least 2 embeds to be done: header and footer code sections. Every template parsing you save counts.
You can use embeds for several things:
- to nest the same module inside itself or modules which have conflicting variables inside each other, because this can cause serious conflicts on the same template. Like a
exp:channel:entries
tag inside another one or aexp:comment:entries
inside aexp:channel:entries
; - to have a different template cache time on an embed from the template it's loaded;
- to have similar templates loading at different URLs, if you are too scared of routes. Something like
/cars
and/boats
loading the same template;