Skip to content

Commit

Permalink
Add example of adding a map to an array in a complex object
Browse files Browse the repository at this point in the history
  • Loading branch information
amalagaura committed Nov 14, 2020
1 parent 03003d0 commit c5d559f
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
17 changes: 17 additions & 0 deletions examples/playground/overlays/example-append-map-to-array/_data.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
id: 1
type: book
awards:
books:
- id: 1
title: International Botev
reviewers:
- id: 2
name: PersonB
- id: 2
title: Dayton Literary Peace Prize
reviewers:
- id: 3
name: PersonC
- id: 3
title: Example Book
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#@ load("@ytt:overlay", "overlay")

#! Add a map to an array of maps:

#@overlay/match by=overlay.all
---
awards:
books:
#@overlay/match by=overlay.all, expects="1+"
-
#@overlay/match missing_ok=True
reviewers:
#@overlay/append
- id: 1
name: Person A
1 change: 1 addition & 0 deletions pkg/website/generated.go.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ exampleSets = [
{"id": "example-edit-map-value"},
{"id": "example-remove-map-item"},
{"id": "example-rename-key-in-map"},
{"id": "example-append-map-to-array"},
]
},
{ "id": "getting-started",
Expand Down

0 comments on commit c5d559f

Please sign in to comment.