Recursive

The example in example/recursive showcases how fmf-jinja can run recursively in order to support more complex template outputs. The initial template defines

/main.fmf
vars:
  var1: [2, 3]
  var2:  [x, y]
templates:
  # Use the template folder for the fmf metadata
  path: /template_fmf
copy:
  # Copy the template folder to be used in the final round
  /template: /template

Which is used to generate a new fmf tree from

/template_fmf/main.fmf
templates: /template
vars: {}
{% for A in var1 -%}
/A_{{ A }}:
  vars+:
    varA: {{ A }}
{% for B in var2 -%}
/A_{{ A }}/B_{{ B }}:
  vars+:
    varB: {{ B }}
{% endfor -%}
{% endfor -%}

which overwrites the original main.fmf file.

The second run starts from the generated files:

/main.fmf
templates: /template
vars: {}
/A_2:
  vars+:
    varA: 2
/A_2/B_x:
  vars+:
    varB: x
/A_2/B_y:
  vars+:
    varB: y
/A_3:
  vars+:
    varA: 3
/A_3/B_x:
  vars+:
    varB: x
/A_3/B_y:
  vars+:
    varB: y

This overcomes a limitation in fmf that glob patterns are not supported that would otherwise allow cleaner design of the fmf tree without requiring recursive runs.

Putting all together, running fmf-jinja on this example we get:

$ fmf-jinja -r example/recusive generate -o output
$ tree output
output/
├── .fmf
│   └── version
├── A_2
│   ├── B_x
│   │   └── file.yaml
│   └── B_y
│       └── file.yaml
├── A_3
│   ├── B_x
│   │   └── file.yaml
│   └── B_y
│       └── file.yaml
└── main.fmf