Skip to content

Commit 0b2c1cf

Browse files
authored
Support template recursion (#11)
1 parent 0f66782 commit 0b2c1cf

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

ripoff_file.go

+3-6
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,9 @@ func concatRows(templates *template.Template, existingRows map[string]Row, newRo
5555
if err != nil {
5656
return err
5757
}
58-
for templateRowId, templateRow := range ripoff.Rows {
59-
_, rowExists := existingRows[templateRowId]
60-
if rowExists {
61-
return fmt.Errorf("row %s is defined more than once", rowId)
62-
}
63-
existingRows[templateRowId] = templateRow
58+
err = concatRows(templates, existingRows, ripoff.Rows, enums)
59+
if err != nil {
60+
return err
6461
}
6562
} else {
6663
existingRows[rowId] = row
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
rows:
2+
{{ .rowId }}:
3+
url: {{ .avatarUrl }}

testdata/import/templates/template_users.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ rows:
33
users:uuid({{ $email }}):
44
email: {{ $email }}
55
avatar_id: avatars:uuid({{ $avatarUrl }})
6+
# Template recursion is supported.
67
avatars:uuid({{ $avatarUrl }}):
7-
url: {{ $avatarUrl }}
8+
template: template_avatar.yml
9+
avatarUrl: {{ $avatarUrl }}
810
{{ end }}

0 commit comments

Comments
 (0)