I have the following yaml template : consultant.yaml
title: myTitle
content: myContent
cards:
- card:
title: Title 1
args:
arg1: "blablabla 1"
arg2: "blablabla 2"
- card:
title: Title
args:
arg1: "blablabla 3"
arg2: "blablabla 4"
arg3: "blablabla 5"
I want to display each arg[x] of my card element using an index and not the key itself. I read about the index
function and it seems to be possible.
Hugo doc :
Soluton 1 : index COLLECTION INDEX
Solution 2 : index COLLECTION KEY
I want to use Solution 1
.
I have the following HTML template : single.html
{{ range .Site.Data.consultant.consultant.cards }}
<div class="col-md-4 col-lg-4">
<div class="">
<div class="">
<h3 class=""> {{.title}} </h3>
</div>
<p>{{.args}}</p>
<p>{{ (index .args).arg1}}</p>
<p>{{ (index .args). 0}}</p>
</div>
</div>
{{end}}
- the first
p
element display a mapmap[arg1:blablabla 1 arg2:blablabla 2]
=> OK - the second
p
element display the first valueblablabla 1
=> OK - the third
p
element display a mapmap[arg1:blablabla arg2:blablabla 2]
=> KO.
The third p
should display the first element just like the second one and I don’t get why.