forked from pallets/jinja
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for auto-indented blocks
Fixes pallets#178 Blocks now support a new syntax '{%* ... %}' that alings the indentation of multiline string with the block statement itself. This is especially useful with YAML or other languages where indentation matter. Example: labels.j2: ``` tla: webtool env: {{ env }} ``` deployment.yaml.j2: ``` apiVersion: extensions/v1beta1 kind: Deployment metadata: labels: {% include 'labels.j2' %} name: webtool spec: selector: matchLabels: {% include 'labels.j2' %} strategy: type: Recreate ``` ...renders to broken YAML: ``` apiVersion: extensions/v1beta1 kind: Deployment metadata: labels: tla: webtool env: qa name: webtool spec: selector: matchLabels: tla: webtool env: qa strategy: type: Recreate ``` deployment_new_syntax.yaml.j2: ``` apiVersion: extensions/v1beta1 kind: Deployment metadata: labels: {%* include 'labels.j2' %} name: webtool spec: selector: matchLabels: {%* include 'labels.j2' %} strategy: type: Recreate ``` ...renders correctly: ``` apiVersion: extensions/v1beta1 kind: Deployment metadata: labels: tla: webtool env: qa name: webtool spec: selector: matchLabels: tla: webtool env: qa strategy: type: Recreate ```
- Loading branch information
1 parent
c89351f
commit cdad187
Showing
3 changed files
with
44 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters