Skip to content

Commit

Permalink
docs: document the additional furops features
Browse files Browse the repository at this point in the history
  • Loading branch information
veith committed Mar 30, 2022
1 parent c6db6b1 commit 851757b
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 6 deletions.
24 changes: 24 additions & 0 deletions furops/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,19 +104,43 @@ structure:
template: "templatefile.tpl"
condition: ""
notes: "This field is informative only"
repeatBy: ""
repeatAs: ""
repeatExpressions:
UTab: "ToUpper(Tab)"
```

### target
The target is a expression like default or expression in the variables definition.
You can construct a target with the variables and given functions.

Use `target: "'STDOUT'"` to write to STDOUT

### template
This field defines which template is to be used for generating the target.


### condition
Enter a condition which resolves to **bool** if you want to render or not to render the template.

### repeatBy, repeatAs, repeatExpressions
You can repeat a template file generation with the values of a stringlist.

The following example will repeat the *stringlist* **Tabs** where the variable **Tab** will contain the string content.
By using the repeatExpressions you can create more variables, based on the iteration.
The variable that you have defined in **repeatAs** is usable in the complete structure definition.

```yaml
- target: "'./output/tabcontent-' + Tab + '.md'"
template: "sample.md.tpl"
notes: "Just to show the repeat feature"
repeatBy: "Tabs"
repeatAs: "Tab"
condition: "Tab != 'main'"
repeatExpressions:
upper: "ToUpper(Tab)"
```

## Expressions
We follow the philosophy that the template only has to render and everything that is needed for this is resolved via the expressions.

Expand Down
8 changes: 4 additions & 4 deletions furops/internal/root/fps.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ type Structure struct {
Template string `yaml:"template"`
Notes string `yaml:"notes"`
Target string `yaml:"target"`
Condition string `yaml:"condition"` // bool expression to define if file is generated
RepeatBy string `yaml:"repeatBy"` // name of a stringlist var
RepeatAs string `yaml:"repeatAs"` // varname of the stringlist item
Expressions map[string]string `yaml:"expressions"` // expression to construct variable contents
Condition string `yaml:"condition"` // bool expression to define if file is generated
RepeatBy string `yaml:"repeatBy"` // name of a stringlist var
RepeatAs string `yaml:"repeatAs"` // varname of the stringlist item
Expressions map[string]string `yaml:"repeatExpressions"` // expression to construct variable contents
}
4 changes: 2 additions & 2 deletions furops/sample/patterns/stringlist/fps.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ structure:

- target: "'./output/tabcontent-' + Tab + '.md'"
template: "sample.md.tpl"
notes: "Just to show the stringlist feature"
notes: "Just to show the repeat feature"
repeatBy: "Tabs"
repeatAs: "Tab"
condition: "Tab != 'main'"
expressions:
repeatExpressions:
upper: "ToUpper(Tab)"

0 comments on commit 851757b

Please sign in to comment.