Conditional content block inclusion for Foliant.
Project description
# Conditional Blocks for Foliant
This preprocessors lets you exclude parts of the source based on flags defined in the project config and environment variables.
## Installation
```shell
$ pip install foliantcontrib.flags
```
## Config
Enabled project flags are listed in `preprocessors.flags`:
```yaml
preprocessors:
flags:
- foo
- bar
```
To set flags for the current session, define `FOLIANT_FLAGS` environment variable:
```shell
$ FOLIANT_FLAGS="spam, eggs"
```
You can use commas, semicolons, or spaces to separate flags.
## Usage
Conditional blocks are enclosed between `<<if>...</if>` tags:
```markdown
This paragraph is for everyone.
<<if flags="management">
This parapraph is for management only.
</if>
```
A block can depend on multiple flags. You can pick whether all tags must be present for the block to appear, or any of them (by default, `kind="all"` is assumed):
```markdown
<<if flags="spam, eggs" kind="all">
This is included only if both `spam` and `eggs` are set.
</if>
<<if flags="spam, eggs" kind="any">
This is included if both `spam` or `eggs` is set.
</if>
```
You can also list flags that must *not* be set for the block to be included:
```markdown
<<if flags="spam, eggs" kind="none">
This is included only if neither `spam` nor `eggs` are set.
</if>
```
This preprocessors lets you exclude parts of the source based on flags defined in the project config and environment variables.
## Installation
```shell
$ pip install foliantcontrib.flags
```
## Config
Enabled project flags are listed in `preprocessors.flags`:
```yaml
preprocessors:
flags:
- foo
- bar
```
To set flags for the current session, define `FOLIANT_FLAGS` environment variable:
```shell
$ FOLIANT_FLAGS="spam, eggs"
```
You can use commas, semicolons, or spaces to separate flags.
## Usage
Conditional blocks are enclosed between `<<if>...</if>` tags:
```markdown
This paragraph is for everyone.
<<if flags="management">
This parapraph is for management only.
</if>
```
A block can depend on multiple flags. You can pick whether all tags must be present for the block to appear, or any of them (by default, `kind="all"` is assumed):
```markdown
<<if flags="spam, eggs" kind="all">
This is included only if both `spam` and `eggs` are set.
</if>
<<if flags="spam, eggs" kind="any">
This is included if both `spam` or `eggs` is set.
</if>
```
You can also list flags that must *not* be set for the block to be included:
```markdown
<<if flags="spam, eggs" kind="none">
This is included only if neither `spam` nor `eggs` are set.
</if>
```
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for foliantcontrib.flags-1.0.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1457c650700a1c77a8b1c10fa42ef90e65b052c803815bbdf0f6b4290af5d1d8 |
|
MD5 | b30b64d8fe77ad23f197f065a68ca6d2 |
|
BLAKE2b-256 | 8eaaf392ce1588632dedd8e85c1a07e9301f926d8a0ee5a846b535e3f90db80c |
Close
Hashes for foliantcontrib.flags-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e17c797fd3afcf515ec2a937ebc63f65119c562ad29ba40bb6fb66a117123c48 |
|
MD5 | fa198900f3a7fec7e8f72862ef2831aa |
|
BLAKE2b-256 | 2125fb54a9bb89d729d6318cb4fba7aed8c18171cb88467edaa06604d35f69c1 |