JINJA ¶
Renders JINJA2 files, and whole directories of files. Allows to render by pattern.
All includes and extends are by default looking in current working directory path.
:j2:render ¶
Package to import |
Single task to import |
PIP package to install |
Stable version |
---|---|---|---|
pip install rkd== SELECT VERSION |
Renders a single file from JINJA2.
Example of usage:
rkd :j2:render -s SOURCE-FILE.yaml.j2 -o OUTPUT-FILE.yaml
Tip
This Task is ready to be imported and executed, but can be also easily extended.
- class rkd.core.standardlib.jinja. FileRendererTask [source] ¶
-
Renders a .j2 file using environment as input variables
API
To be used inside “execute”:
-
render(): Allows to render a JINJA template (from a string)
-
render_to_file(): Renders a template to a file
Example of API usage in YAML (if want to inherit the task):
execute: | with open('some-file.j2', 'r') as f: task.render_to_file(f.read(), ctx, 'output.html')
Usage
./rkdw :j2:render --source=src.j2 --output=dst.html
-
Jinja2Language ¶
Tip
This class was designed especially with MultiStepLanguageAgnosticTask in mind, but can be easily used without it.
- class rkd.core.standardlib.jinja. Jinja2Language [source] ¶
-
Jinja2 language extension for MultiStepLanguageAgnosticTask
Usage using MultiStepLanguageAgnosticTask
version: org.riotkit.rkd/yaml/v2 imports: - rkd.core.standardlib.jinja.Jinja2Language tasks: :render: steps: | #!rkd.core.standardlib.jinja.Jinja2Language Test - RKD_PATH environment variable is {{ RKD_PATH }}. System PATH is {{ PATH }}, using shell {{ SHELL }}
Usage standalone
version: org.riotkit.rkd/yaml/v2 imports: - rkd.core.standardlib.jinja.Jinja2Language tasks: :render: extends: rkd.core.standardlib.jinja.Jinja2Language input: | Test - RKD_PATH environment variable is {{ RKD_PATH }}. System PATH is {{ PATH }}, using shell {{ SHELL }}
./rkdw :render ./rkdw :render --output=/tmp/rendered
:j2:directory-to-directory ¶
Package to import |
Single task to import |
PIP package to install |
Stable version |
---|---|---|---|
pip install rkd== SELECT VERSION |
Renders all files recursively in given directory to other directory.
Can remove source files after rendering them to the output files.
Tip
Use this Task in a docker entrypoint to create fully customizable configurations inside docker containers.
Tip
Note: Pattern is a regexp pattern that matches whole path, not only file name
Tip
Note: Exclude pattern is matching on SOURCE files, not on target files
Example usage:
rkd :j2:directory-to-directory \
--source="/some/path/templates" \
--target="/some/path/rendered" \
--delete-source-files \
--pattern="(.*).j2"