Cascade

Hex.pmhex.pmDocumentation

Generate code from templates.

Cascade provides an easy to use interface for generating code from a set of templates. It's main features are:

Usage

You can generate a new template under your mix project by running:

$ mix cascade template -- --name my_template
* creating templates/my_template/PLACEHOLDER.md
* creating lib/cascade/templates/my_template.ex

This generates two files:

If you now run mix cascade.help you will see the newly added template in the list of available templates:

$ mix cascade.help
The following templates are available:

  my_template  # TODO: Add shortdoc
  template     # Generates \a new template

Run mix cascade NAME to generate code from the given template
Run mix cascade.help NAME to see help for a specific template

You can generate some code using the my_template template by running:

$ mix cascade my_template

This will generate all code associated to the given template. In this case it will only generate the PLACEHOLDER.md which was added by the mix cascade command.

You can check the help message of the newly created template by running:

$ mix cascade.help my_template

Implementing your template

You are now free to implement your actual template logic. You are able to:

For more details check the Cascade.Template docs.

Installation

The package can be installed by adding cascade to your list of dependencies in mix.exs:

def deps do
  [
    {:cascade, "~> 0.2.0"}
  ]
end

License

Copyright (c) 2023 Panagiotis Nezis, Sportradar

Cascade is released under the MIT License. See the LICENSE file for more details.