https://github.com/foliant-docs/foliantcontrib.yaml_include
Extension for Foliant to include YAML-files in config and xml-tag parameters.
https://github.com/foliant-docs/foliantcontrib.yaml_include
Last synced: 5 months ago
JSON representation
Extension for Foliant to include YAML-files in config and xml-tag parameters.
- Host: GitHub
- URL: https://github.com/foliant-docs/foliantcontrib.yaml_include
- Owner: foliant-docs
- License: mit
- Created: 2021-03-10T06:47:32.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-05-07T10:16:20.000Z (about 5 years ago)
- Last Synced: 2025-09-28T00:23:00.682Z (9 months ago)
- Language: Python
- Size: 9.77 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: changelog.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://pypi.org/project/foliantcontrib.yaml_include/) [](https://github.com/foliant-docs/foliantcontrib.yaml_include)
# YAMLInclude Extension
YAMLInclude is a configuration extension for Foliant to include parts of configuration from YAML-files.
It resolves `!include` YAML tag in the project config and inside XML-tags parameters.
## Installation
```bash
$ pip install foliantcontrib.yaml_include
```
## Usage
The syntax of the `!include` YAML tag is:
`!include [#]`
Where `file` may be
- path to local file in Foliant project root,
- direct link to a file on remote server.
An optional `#` part is used to get a key from the mapping stored inside ``.
**Including a local file**
Config example:
```yaml
chapters: !include chapters.yml
```
In this example the `chapters.yml` file should be placed in your Foliant project root.
if the contents of `chapters.yml` are as follows:
```yaml
# chapters.yml
- index.md
- description.md
```
then the resulting config after applying the extension will be:
```yaml
chapters:
- index.md
- description.md
```
**Including part of a local file**
Config example:
```yaml
chapters: !include chapters.yml#chapters_for_pdf
```
In this example the `chapters.yml` file should be placed in your Foliant project root.
if the contents of `chapters.yml` are as follows:
```yaml
# chapters.yml
chapters_for_site:
- index_site.md
- description_site.md
chapters_for_pdf:
- index.md
- description.md
```
then the resulting config after applying the extension will be:
```yaml
chapters:
- index.md
- description.md
```
**Including a remote file**
Config example:
```yaml
chapters: !include http://example.com/chapters.yml
```
In this example the `chapters.yml` file is stored on the website `http://example.com/`.
if the contents of `chapters.yml` are as follows:
```yaml
# chapters.yml
- index.md
- description.md
```
then the resulting config after applying the extension will be:
```yaml
chapters:
- index.md
- description.md
```
**Including part of a remote file**
Config example:
```yaml
chapters: !include http://example.com/chapters.yml#chapters_for_pdf
```
In this example the `chapters.yml` file is stored on the website `http://example.com/`.
if the contents of `chapters.yml` are as follows:
```yaml
# chapters.yml
chapters_for_site:
- index_site.md
- description_site.md
chapters_for_pdf:
- index.md
- description.md
```
then the resulting config after applying the extension will be:
```yaml
chapters:
- index.md
- description.md
```