Skip to content
This repository has been archived by the owner on May 29, 2024. It is now read-only.

Creator: The `transform` Action

Tako Schotanus edited this page Jul 29, 2019 · 2 revisions

In the section on Available Actions the transform Action was shortly mentioned but explaining everything in full there would have made the documentation too unwieldy.

So transformers take some text as input, transform it somehow and generate that text as output.

Available Transformers

Name Function Arguments
insertAfter Inserts text after the first line where a pattern was found pattern - The pattern to look for
text / lines / fromFile - See below
insertBefore Inserts text before the first line where a pattern was found pattern - The pattern to look for
text / lines / fromFile - See below
insertAtStart Inserts text at the start of the text text / lines / fromFile - See below
insertAtEnd Inserts text at the end of the text text / lines / fromFile - See below
insertAtStartOfList Inserts text at the start of the text, treating the text as a comma-separated list where each line, except the last, should terminate with a comma. Commas will automatically be inserted or removed where necessary text / lines / fromFile - See below
insertAtEndOfList Inserts text at the end of the text, treating the text as a comma-separated list where each line, except the last, should terminate with a comma. Commas will automatically be inserted or removed where necessary text / lines / fromFile - See below
replace Inserts text replacing the first line where a pattern was found pattern - The pattern to look for
text / lines / fromFile - See below
cases Performs a Go Template-like transformation props - The properties to use for
substitutions. Optional, if not present
the properties passed to the
Generator will be used instead
blocks Takes the block of text between the lines marked by the start and end patterns and then transforms that text using any of the above transformers start - The start pattern
end - The end pattern
... - A nested transformer

Text Input

Many times in the above list the following three properties were mentioned: text / lines / fromFile. What this means is that you can choose any one (and exactly one) of these options:

  • text - The literal text to use for the substitution
  • lines - A list of text lines to use for the substitution
  • fromFile - The contents of the given file will be used for the substitution. The path is relative to the Generator's resource directory