Skip to content

Commit 2b95697

Browse files
Add second nesting level
1 parent a543d2e commit 2b95697

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

partials/private/import.html

+9-1
Original file line numberDiff line numberDiff line change
@@ -60,18 +60,26 @@
6060
{{/* We look for the matching data file located in `data/netlifycms/{Type}/{File}.yaml` */}}
6161
{{ with index site.Data.netlifycms (pluralize $type) }}
6262
{{ $with := index . $file }}
63+
{{/* If we find a "." in the File string, it means user is trying to access a nested value.
64+
We'll split the string and check for two nesting level max
65+
*/}}
6366
{{ $file_split := split $file "." }}
6467
{{ if eq (len $file_split) 2 }}
68+
{{/* We have something like `import fields greeting.spanish */}}
6569
{{ $with = index . (index $file_split 0) (index $file_split 1) }}
70+
{{ else if eq (len $file_split) 3 }}
71+
{{/* We have something like `import fields greeting.spanish.singular */}}
72+
{{ $with = index . (index $file_split 0) (index $file_split 1) (index $file_split 2) }}
6673
{{ end }}
74+
6775
{{ with $with }}
6876
{{ $return = . }}
6977
{{ with $extend }}
7078
{{ $return = merge $return . }}
7179
{{ end }}
7280
{{ else }}
7381
{{ $message := printf "We couldn't find %s/%s" $type $file }}
74-
{{ with split $file "." }}
82+
{{ with $file_split }}
7583
{{ if gt . 2 }}
7684
{{ $message = print $message " because object depth is limited to 2" }}
7785
{{ end }}

0 commit comments

Comments
 (0)