Skip to content
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

docs: Updating !include documentation for clarity #1496

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
44 changes: 31 additions & 13 deletions docs/configuring.md
Original file line number Diff line number Diff line change
Expand Up @@ -383,19 +383,7 @@ cannot use Jinja templating in your answers.
The `copier.yml` file supports multiple documents as well as using the `!include` tag to
include settings and questions from other YAML files. This allows you to split up a
larger `copier.yml` and enables you to reuse common partial sections from your
templates. When multiple documents are used, care has to be taken with questions and
settings that are defined in more than one document:

- A question with the same name overwrites definitions from an earlier document.
- Settings given in multiple documents for `exclude`, `skip_if_exists`,
`jinja_extensions` and `secret_questions` are concatenated.
- Other settings (such as `tasks` or `migrations`) overwrite previous definitions for
these settings.

!!! hint

You can use [Git submodules](https://git-scm.com/book/en/v2/Git-Tools-Submodules)
to sanely include shared code into templates.
templates.

!!! example

Expand Down Expand Up @@ -432,6 +420,36 @@ settings that are defined in more than one document:
- "pyproject.toml"
```

The syntax of a single include is:

```yaml
---
!include filename.yml
---
```

the `---` on new lines are essential, but you don't need to duplicate them if you have
two `!include` directives.

!!! hint

When working with multiple documents, you can use [`exclude`][exclude]
to exclude them from the rendered project.

When multiple documents are used, care has to be taken with questions and
settings that are defined in more than one document:

- A question with the same name overwrites definitions from an earlier document.
- Settings given in multiple documents for `exclude`, `skip_if_exists`,
`jinja_extensions` and `secret_questions` are concatenated.
- Other settings (such as `tasks` or `migrations`) overwrite previous definitions for
these settings.

!!! hint

You can use [Git submodules](https://git-scm.com/book/en/v2/Git-Tools-Submodules)
to sanely include shared code into templates.

## Conditional files and directories

You can take advantage of the ability to template file and directory names to make them
Expand Down
Loading