Twig embed vs extends

I just had a look into the blog skeleton which uses antimatter theme. I noticed that some template files uses “extends” and other do use “embed”. For example item.html.twig uses:

{% embed ‘partials/base.html.twig’ %}

{% endembed %}

I changed it to:

{% extends ‘partials/base.html.twig’ %}

and couldn’t see any difference. It works as before.

So could anyone tell me whats the difference between those two and when use to which?

Best to read the official documentation: http://twig.sensiolabs.org/doc/tags/embed.html

I read this before and I get the basic Idea, but I still don’t quite understand why embed is used on the item.html.twig :frowning:

I probably was using something before that required embed and then removed it or refactored it. embed is similar to extends but lets do more such as multiple levels of block extending.

Mhh… all right! If I understood correctly I would use extends to include the content/skeleton of my main template base.html.twig into the child template blog.html.twig. If I need to include another child-template inside my blog.html.twig which has some blocks I would like to override then I have to use embed. Is this right? Or

Easiest way to think about it is to use extends until you run into a situation where you can’t. Then you are probably going to need embed :slight_smile:

Ah that’s a good one! I’ll keep that in mind Thank you. :slight_smile: