Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
- What is a Template Engine? 3:45
- Installing Twig 4:43
- Twig View 5 questions
- Template Language 4:28
- Escaping and Comments 3:53
- Twig Syntax 5 questions
- The Structure of Control 6:13
- Working with Date 3:17
- Filters and Functions 7 questions
- Combining Templates 7:09
- Adding a Second Page 3:23
- Sharing 6 questions
- Custom Functions with Macros 4:22
- Importing and Using Macros 3:28
- Multiple Macros 2:51
- Custom Functions 5 questions
- Extending Twig and Beyond 1:51
- Your next step 1 question

- 2x 2x
- 1.75x 1.75x
- 1.5x 1.5x
- 1.25x 1.25x
- 1.1x 1.1x
- 1x 1x
- 0.75x 0.75x
- 0.5x 0.5x
One of the most powerful features of a template engine is the way we can use a layout template to create the overall structure of a page while allowing us to fill in specific details. We do this by extending templates much like we can extend classes in object-oriented programming. Besides extending with blocks, Twig can also include other template files.
The extends tag can be used to extend a template from another one.
A child template might look like this:
{% extends "base.html" %}
{% block title %}Index{% endblock %}
{% block head %}
{{ parent() }}
<style type="text/css">
.important { color: #336699; }
</style>
{% endblock %}
{% block content %}
<h1>Index</h1>
<p class="important">
Welcome to my awesome homepage.
</p>
{% endblock %}
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up