-
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow dict to create nested structures #6497
Comments
/cc @regisphilibert |
Not sure to understand but it seems we're using parsed data as key. Could we also do:
|
Your construct is very ambiguous. Assuming that "." is always used as a separator will not work. I may have another idea, though. Will be back in a minute ... |
If we allow a map to be passed in as the (optional) first argument, we could do something ala:
|
Not sure to follow all those
|
My example was slightly wrong:
Which I guess I with the current Hugo could write as:
But that is not possible to do in a loop. I guess it boils down to this line: {{ $config = $config | dict "markup" "value" }} Which, when thinking about it, could be rewritten as: {{ $config = $config | merge (dict "markup" "value" )}} OK, I'll try to implement the docs changes with the above and see if that works. |
OK; so I managed to get my code toggle shortcode change working with this construct: DELETED Not particularly simple ... I suspect that my initial suggestion (first comment) was the most sensible one, but I will let this one linger .... |
I use merge a lot for building dynamic maps within loops, but I found it takes a toll on build time. As an aside: If you're interested in improving overall Hugo handling of data, I'd love to dig up this old thing: #5604 |
Interested maybe, time, no. |
So, I deleted my "suggested approach" above -- I just couldn't get it right. I'm a little bit tired, but it shows that it's much harder than it should. I have a patch ready that allows string slices as keys in {{ $sections := (split . ".") }}
{{ $configSection := index $.Site.Data.docs.config $sections }}
{{ $code = dict $sections $configSection }} |
I'm guessing here because not sure what the value of Pending they both have an equal numbers of item, key/value pairs are created by "paralelling" the two slices? |
Scratch the above, I understood by reading #6500 |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
I'm working on documentation for the revised "markdown etc." and thought I would save some time by code generation. Which would be exellent had it not been for Hugo's limited map support.
What I would want is something ala:
The
$sections
above is a string slice and would make sure that I could present the docs on the correct level in a "copy pastable" friendly version.The text was updated successfully, but these errors were encountered: