Create a dict with $

I have realized that widgets’ context didn’t get the initial context. Here is what I had written:

{{ $context := (dict "$" $._c "WidgetArea" $._wa "Widget" .) }}

But the embedded template doesn’t act as I expected. With {{ print . }} inside the widget’s template, I only get this:

map[$:Page("Adrien Poupin — Artiste lyrique — Ténor") WidgetArea:homepage Widget:0xc430814600]

Is it possible to get the whole context?

Looks complete to me.

But somehow .Site is not passed in the context, which I cannot understand for now…

Would there be a way to do like the following:

    {{ $context := $ }}
    {{ $context["WidgetArea"] = $wa }}
    {{ $context["Widget"] = . }}

…which would make the whole thing clearer?

No…

Actually if I do

{{ $context := (dict "a" $._c "WidgetArea" $._wa "Widget" .) }}

Then with {{ printf "%#v" .a }} it prints the following:

&hugolib.PageOutput{Page:(*hugolib.Page)(0xc4200d6000), paginator:(*hugolib.Pager)(nil), paginatorInit:sync.Once{m:sync.Mutex{state:0, sema:0x0}, done:0x0}, targetPathDescriptor:hugolib.targetPathDescriptor{PathSpec:(*helpers.PathSpec)(0xc4200a2180), Type:output.Format{Name:"HTML", MediaType:media.Type{MainType:"text", SubType:"html", Suffix:"html"}, Path:"", BaseName:"index", Rel:"canonical", Protocol:"", IsPlainText:false, IsHTML:true, NoUgly:false, NotAlternative:false}, Kind:"home", Sections:[]string(nil), BaseName:"_index", Dir:"", LangPrefix:"", URL:"/", Addends:"", ExpandedPermalink:"", UglyURLs:false}, outputFormat:output.Format{Name:"HTML", MediaType:media.Type{MainType:"text", SubType:"html", Suffix:"html"}, Path:"", BaseName:"index", Rel:"canonical", Protocol:"", IsPlainText:false, IsHTML:true, NoUgly:false, NotAlternative:false}}

But if now I pass the context with $:

{{ $context := (dict "$" $._c "WidgetArea" $._wa "Widget" .) }}

it only prints <nil>.

For now, what I did is to pass the context as Context. So you access it through .Context. See https://github.com/lebarde/hugo/commit/b8eae8d8832e81259359257cb8859e74d248c146.

That can be pulled and built directly with git clone https://github.com/lebarde/hugo/commit/b8eae8d8832e81259359257cb8859e74d248c146 and then make hugo.