debrouwere / render

Render text and HTML from Jade, Handlebars, Swig and most other kinds of templates on the command line. Render many files at once and decide where to write to dynamically from the data.
ISC License
17 stars 2 forks source link

Combining --many-pairs and --output seems to fail. #10

Open gcardwel opened 7 years ago

gcardwel commented 7 years ago

I am trying to render multiple output files using the --output and --many-pairs options. The intent is to traverse a map of objects, each of which will generate an output file.

The .yml file looks approximately like this:

enumerations:
  failureModeEncoding:
    file: diag/FailureMode.h
  dtcType:
    file: diag/DTCType.h
  controlModeEncoding:
    file: control/ControlMode.h

and the content of the .hbs file is empty for now.

Using a command line like this:

render --verbose --engine handlebars Enumerations.hbs --context encodings.yml --output '{value.file}' --many-pairs enumerations

I would expect that I would iterate through the enumerations object, getting keys of each "failureModeEncoding, dtcType, controlModeEncoding" and values that are objects containing the "file" key.

Unfortunately, I'm unable to find any substitution string that will go in the --output that works. I usually get some variation of:

Error: Found more than one context set for . Pick an output filename template that produces a unique filename for each set of context.

I'm unable to figure out what context I need to put in the --output parameter, as the unit test cases don't seem to cover this, I don't have a starting point of reference.

gcardwel commented 7 years ago

After some review, it appears that the problem here is that the output path substitution does not support looking up objects in a hierarchy, as in {value.file}. Instead, only a single level of object retrieval is supported. Without changing the library used for output path, this can't be fixed.