I'm fiddling around with Twig and CraftCMS, trying to create a component-based structure... of sorts.
All good so far, except this one thing I got stuck on.
Here's an excerpt from my main layout:
<body>
{% include 'components/header.twig' %}
{% block content %}
woops...
{% endblock %}
{% include 'components/footer.twig' %}
</body>
Which currently works.
But, I'd like to do something like this...
<body>
{% include 'components/header.twig' %}
{% include 'components/main-wrapper.twig' %}
{% include 'components/footer.twig' %}
</body>
Where the main-wrapper.twig is like this, for example:
<main class="main">
{% block content %}
woops...
{% endblock %}
</main>
But it does not work. "woops..." from main-wrapper.twig is displayed.
I've tried a different route without success as well:
<body>
{% include 'components/header.twig' %}
{% embed 'components/main-wrapper.twig' %}
{% block children %}
{# I want to have the block content here... #}
{% endblock %}
{% endembed %}
{% include 'components/footer.twig' %}
</body>
Where the main-wrapper.twig has a block named children instead... but no dice.
It does appear that what I'm trying to do is not possible, which is why I'm asking here as a last resort :)
EDIT:
For those interested, here's what I ended up with, stripped for clarity:
{# default.twig - default layout #}
<!DOCTYPE html>
<html>
<head>
...
</head>
<body>
{% include 'components/header.twig' %}
{% block wrappedContent %}{% endblock %}
{% include 'components/footer.twig' %}
</body>
</html>
{# regular.twig - base page referred in the admin panel #}
{% extends "components/main.twig" %}
{% block content %}
--- stuff for a page ---
{% endblock %}
{# main.twig - wrapper component! :D #}
{% extends "layouts/default.twig" %}
{% block wrappedContent %}
<main class="main">
<div class="main__wrapper">
{% block content %}
wooops...
{% endblock %}
</div>
</main>
{% endblock %}