Template Plugin

extends: copy plugin

Allows you walk sub directories inside a directory and render templates to an output directory

Requirements

This plugin relies on the jinja2 templating engine and 20c's tmpl module

pip install tmpl jinja2

Example

Ctl/config.yaml

ctl:
  plugins:

    - name: template
      type: template
      config:

        # template root directory (path)

        source: source

        # template output directory (path)

        output: output

        # we want to render the templates from
        # `source/dir_1` to `output/dir_2`

        walk_dirs:
          - dir_1

        # yaml files containing template variables
        # that will be exposed to the jinja2 environemnt
        # and can be used when rendering the templates

        vars:
          - Ctl/tmplvars.yaml


  permissions:
    - namespace: ctl
      permission: crud

Ctl/tmplvars.yaml

test_variable: "ctl to control your environment"

Run the command

The plugin will be exposed to the ctl cli as an operation using it's name

ctl template
[2019-10-10 06:46:54,396] [usage] ran command: `template`
[2019-10-10 06:46:54,396] [ctl.plugins.template] Skip dotfiles: True
[2019-10-10 06:46:54,400] [ctl.plugins.template] output/dir_1/template.txt

Usage

Plugin name

This usage documentation assumes that the plugin instance name is template

usage: ctl template [-h] [--no-copy-metadata] [--debug] [--engine ENGINE]
                    [--output OUTPUT] [--no-skip-dotfiles] [--source SOURCE]

optional arguments:
  -h, --help          show this help message and exit
  --no-copy-metadata  DISABLE Copy file metadata
  --debug             debug mode
  --engine ENGINE     template engine (jinja2)
  --output OUTPUT     output directory (output)
  --no-skip-dotfiles  DISABLE Skip dot files
  --source SOURCE     source directory (source)