Skip to content

Commit 8260750

Browse files
committed
Merge pull request #19 from pattern-lab/EvanLovely-patch-1
Adding more info about Template Inheritance
2 parents 16ed789 + 15d09f4 commit 8260750

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,12 @@ Would be used like this in a pattern:
7676

7777
### Template inheritance
7878

79-
The requirements for using template inheritance with Pattern Lab:
79+
How to use [Template Inheritance](http://twig.sensiolabs.org/doc/templates.html#template-inheritance) with Pattern Lab:
8080

81-
* Files can optionally go in `source/_layouts` in order to hide them from the list of patterns.
82-
* Files must have the extension `.twig`
83-
* Files can be extended either by using Pattern Lab's normal shorthand syntax (e.g, `{% extends 'templates-extended-layout'%}`),
84-
or, if they are in the `source/_layouts` directory, by using just the filename as reference (e.g., `{% extends 'extended-layout'%}`).
81+
* Files must have the extension `.twig`.
82+
* Files can be extended either by using Pattern Lab's normal shorthand syntax (e.g, `{% extends 'templates-extended-layout'%}`).
83+
* Files can optionally go in `source/_layouts` in order to hide them from the list of patterns and then you can just use the filename as reference (e.g., `{% extends 'extended-layout'%}`).
84+
* Files that are in the same directory can also just use the file name without the shorthand syntax (however, it must include the extension). So if `file1.twig` and `file2.twig` were in same directory, you could place this code in `file2.twig`: `{% extends 'file1.twig' %}`.
8585

8686
An example of a simple layout called `base.twig` in `source/_layouts`:
8787

@@ -125,6 +125,8 @@ Would be used like this in a pattern:
125125
{% endblock %}
126126
```
127127

128+
All uses of `extends` above also work with `includes`, `embed` and most likely many other Twig Tags. Let us know if you run into interesting or unexpected use cases!
129+
128130
## Extending Twig Further
129131

130132
Twig comes with a number of ways to extend the underlying template parser. You can you can add [extra tags](http://twig.sensiolabs.org/doc/advanced.html#tags), [filters](http://twig.sensiolabs.org/doc/advanced.html#filters), [tests](http://twig.sensiolabs.org/doc/advanced.html#tests), and [functions](http://twig.sensiolabs.org/doc/advanced.html#functions). The Twig PatternEngine tries to simplify these extensions by allowing you to create files in specific folders and then auto-load the extensions for you. Learn more about:

0 commit comments

Comments
 (0)