Skip to content

generate

Source

Hook for generating project outputs. Recursively renders all files and folders in a given target directory to an output. If there is a "templates" directory and a file or directory that matches the templates input param, use that as target. Paths to templates and output are cross-platform but should be written with / path separators.

Inputs

Name Type Default Required Description
templates Union[str, list] templates True Path or list of paths to a templatable directory or file to recursively render the contents.
output str . True Path to put the output file(s).
copy_without_render Union[str, list] [] True List of path to files to only copy and not render.
overwrite_if_exists bool False True Overwrite the output if exists.
skip_if_file_exists bool False True Skip creating if path exists.
skip_overwrite_files list None False List of files to skip generating over if they exist.
render_context dict None False A render context that invalidates the default context.
extra_context Union[str, dict, List[dict]] None False A map / list of maps to use as extra context when rendering. Lists inputs are merged together as lists themselves don't make sense.
file_system_loader Union[str, list] . True List of paths or string path to directory with templates to load from. Docs.

Arguments

Position Argument Type
1 templates Union[str, list]
2 output str

Returns

None

Examples

Basic

The most minimal implementation.

stuff: things
generate_example->: generate path/to/template/file/or/dir output/path

With specific context

generate with specific context:
  _>: generate
  templates: path/to/template/file/or/dir
  output: output/path
  render_context:
    stuff: things

With extra context

stuff: things
generate with specific context:
  _>: generate
  templates: path/to/template/file/or/dir
  output: output/path
  extra_context:
    foo: bar

Copy without render

In case you don't want to render a file (for example a template), you can copy without rendering.

expanded:
  ->: generate render_src output
  copy_without_render:
    - ./render_src/.hidden.yaml
    - ./render_src/no-render/*