How to merge YAML arrays?

后端 未结 5 1683
旧时难觅i
旧时难觅i 2020-11-29 23:16

I would like to merge arrays in YAML, and load them via ruby -

some_stuff: &some_stuff
 - a
 - b
 - c

combined_stuff:
  <<: *some_stuff
  - d
  -         


        
5条回答
  •  天命终不由人
    2020-11-29 23:55

    You can merge mappings then convert their keys into a list, under these conditions:

    • if you are using jinja2 templating and
    • if item order is not important
    some_stuff: &some_stuff
     a:
     b:
     c:
    
    combined_stuff:
      <<: *some_stuff
      d:
      e:
      f:
    
    {{ combined_stuff | list }}
    

提交回复
热议问题