moban icon indicating copy to clipboard operation
moban copied to clipboard

Configuration data structure transforms

Open jayvdb opened this issue 6 years ago • 4 comments

jinja is a horrible language to transform data structures before they are used by a block in another template.

I tried to fill extra_dependencies using jinja set. {% set extra_dependencies = ... %} does work, but it requires the exact same structure.

I couldnt transform existing data from a different structure.

Anyway, there could be a better way..

https://github.com/coala/coala-bears/blob/master/.moban.yaml overrides https://github.com/coala/coala-bears/blob/master/bear-requirements.yaml which has

pip_requirements:
  HTTPolice:
    version: ~=0.5.2
  aenum:
    version: ~=2.0.8

I want it to look like

extra_dependencies:
  - all:
    - HTTPolice~=0.5.2
    - aenum~=2.0.8

One way to do this is to incorporate a transform system like https://github.com/dreftymac/dynamic.yaml

Another is https://github.com/moremoban/moban/issues/23

I assume the same problem occurs in reverse. e.g. If I have configuration data in format

a:
  - b: z
    c: y
    d: x

But a template supports multiple values, and thus wants it in a structure like

a:
  b:
    - z
  c:
    - y
  d:
    - x

jayvdb avatar May 29 '18 16:05 jayvdb