This is something suggested by @cboettig, and which I immediately ran into on dfalster/tree-p#9 (private repo currently). We have a makerfile that includes targets like:
output/leaf_traits.csv:
depends: leaf_traits
rule: export_csv
target_argument_name: filename
output/growth_mortality_traits.csv:
depends: growth_mortality_traits
rule: export_csv
target_argument_name: filename
It might be nice to be able to remove the duplication in a couple of places.
Most simply, the output directory (ideally there won't be that many file targets in a maker workflow, but repetition is bad form). The simplest option I can think of there is to use whisker, so that we'd have:
{{output_dir}}/leaf_traits.csv:
depends: leaf_traits
rule: export_csv
target_argument_name: filename
{{output_dir}}/growth_mortality_traits.csv:
depends: growth_mortality_traits
rule: export_csv
target_argument_name: filename
and then another section in the makerfile:
variables:
output_dir: output
The only real sticking point here is that will fail miserably if a whisker variable is missing because the mustache spec says by default that missing variables result in the empty string. This issue suggests that throwing errors might be a possibility.
A more complicated form of templating (which is then more prone to odd corner cases) would be to define whole template rules. So we'd have:
output/{{filename}}.csv:
depends: {{object}}
rule: export_csv
target_argument_name: filename
somehow fill that in for the two cases above.
Of course, it should be fairly easy for users to manually template their own files prior to running maker, so the simplest solution might be to trial some forms of templating outside the package and incorporate what works.