I have a breadcumb partial template.
To use it I need to pass a dictionary of dictionaries, something like this:
{{ partial "breadcumb" ( dict "context" . "items" ( dict "1" ( dict "Url" "someUrl" "Name" "SomeName" ) "2" ( dict "Url" "someUrl" "Name" "SomeName" ) "3" ( dict "Url" "someUrl" "Name" "SomeName" ) ) ) }}
There is a better way to write this piece of code?
I tried something like this:
{{ partial "breadcumb" ( dict "context" . "items" ( dict "1" ( dict "Url" "someUrl" "Name" "SomeName" ) "2" ( dict "Url" "someUrl" "Name" "SomeName" ) "3" ( dict "Url" "someUrl" "Name" "SomeName" ) ) ) }}
But it show the “unclosed action” error.
Thanks.
2 Likes
Unfortunately, the lack of newline support in actions appears to be a Go template package limitation:
Except for raw strings, actions may not span newlines, although comments can.
Yeah, you are right.
As a workaround I did this:
{{ $bLink1 := ( dict “Url” “someUrl” “Name” “SomeName” ) }}
{{ $bLink2 := ( dict “Url” “someUrl” “Name” “SomeName” ) }}
{{ $bLink3 := ( dict “Url” “someUrl” “Name” “SomeName” ) }}
{{ partial “breadcumb” ( dict “context” . “items” ( dict “1” $bLink1 “2” $bLink2 “3” $bLink3 ) ) }}
1 Like
yaaax
4
Hi there,
Still no newline support right?
This feature is related to this GitHub issue, which was closed in the late of 2020. Yet, this does not work as expected.
bep
6
Note that this will be fixed in the next Hugo version.
4 Likes
system
Closed
7
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.