This repository has been archived by the owner on Mar 31, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 70
When to use include, extends, and embed
Brian Lewis edited this page Mar 9, 2017
·
6 revisions
This is just a placeholder (and reminder) to document the proper use of include, extends, and embed.
{% block link_content %}
{{ link_content }}
{% endblock %}
</a>
Standard "use another component but change the variables."
{% include "@atoms/01-links/link/link.twig"
with {
"link_content": "This is included",
"link_url": "https://www.fourkitchens.com",
}
%}
This would be useful if you wanted to link something other than text, like an image. The image include would go inside the block.
{% extends "@atoms/01-links/link/link.twig" %}
{% block link_content %}
{% include "@atoms/04-images/00-image/image.twig"
with {
"img_src": "http://placeimg.com/1200/800/tech",
}
%}
{% endblock %}
The problem is, link also wants a url, and has optional class modifiers, so we need to be able to replace the block, and the variables.
{% embed "@atoms/01-links/link/link.twig"
with {
"link_url": "https://www.fourkitchens.com",
}
%}
{% block link_content %}
{% include "@atoms/04-images/00-image/image.twig"
with {
"img_src": "http://placeimg.com/1200/800/tech",
"img_alt": "This is the image alt text",
}
%}
{% endblock %}
{% endembed %}
- Home
- Basics
- Examples
- Environment-specific or Special Instructions
- Acknowledgements
- To-do
- Contribute to this Wiki!