Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
rybakit authored Mar 13, 2018
1 parent e2198d8 commit 891adca
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Just for example purposes, first create a [global twig variable](http://twig.sen

```php
$twig = new Twig_Environment($loader);
$twig->addGlobal('data', new ArrayObject());
$twig->addGlobal('assets', new ArrayObject());
```

Then build the following set of templates:
Expand All @@ -55,15 +55,15 @@ Then build the following set of templates:
<body>
{% block content '' %}
{{ data.append('/js/layout-header.js') }}
{{ assets.append('/js/layout-header.js') }}
{% block javascripts deferred %}
{% for item in data %}
<script src="{{ item }}"></script>
{% for asset in assets %}
<script src="{{ asset }}"></script>
{% endfor %}
{% endblock %}
{{ data.append('/js/layout-footer.js') }}
{{ assets.append('/js/layout-footer.js') }}
</body>
</html>
Expand All @@ -72,24 +72,24 @@ Then build the following set of templates:
{% extends "layout.html.twig" %}
{% block content %}
{{ data.append('/js/page-header.js') }}
{{ assets.append('/js/page-header.js') }}
{% if foo is not defined %}
{{ include("subpage1.html.twig") }}
{% else %}
{{ include("subpage2.html.twig") }}
{% endif %}
{{ data.append('/js/page-footer.js') }}
{{ assets.append('/js/page-footer.js') }}
{% endblock %}
{# subpage1.html.twig #}
{{ data.append('/js/subpage1.js') }}
{{ assets.append('/js/subpage1.js') }}
{# subpage2.html.twig #}
{{ data.append('/js/subpage2.js') }}
{{ assets.append('/js/subpage2.js') }}
```

The resulting html will be the following:
Expand Down

0 comments on commit 891adca

Please sign in to comment.