Skip to content

Add documentation on pattern context customisation in base template #111

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 7, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,28 @@ You can define a list or a dict or anything that
[`PyYAML`](http://pyyaml.org/wiki/PyYAMLDocumentation)
allows you to create in `yaml` format without creating a custom objects.

## Customising the patterns’ surroundings

All patterns that are not pages are rendered within a base page template, `pages/base.html` by default. The pattern library will render patterns inside the `content` block, which you can tweak to change how patterns are displayed.

You can for example add a theme wrapper around the components:

```html
{% block content %}
{% if pattern_library_rendered_pattern %}
<div class="pattern-library bg bg--light">
{{ pattern_library_rendered_pattern }}
</div>
{% endif %}
{% endblock %}
```

`pattern_library_rendered_pattern` can also be used to do other modifications on the page for the pattern library only, for example adding an extra class to `<body>`:

```html
<body class="{% block body_class %}{% endblock %}{% if pattern_library_rendered_pattern %} pattern-library-template{% endif %}">
```

## Override template tags

The package overrides the following Django tags:
Expand Down