@bep Thanks for the quick response. I must be missing something as well. I get the difference between slice and map, but I’m confused about how to access named parameters within another named parameter.
So, for example, I get that I can use the following shortcode:
{{< fluid_img class="the-class" src="the-img-source" alt="the img description" >}}
And then in my layouts/shortcodes/fluid_img
put the following:
{{range $key,$val := .Params}}
{{$key}}={{$val}} <br>
{{end}}
And get the following:
<div>
alt=the img description <br>
class=the-class <br>
src=the-img-source <br>
</div>
But what @yoshiharuyamashita is looking for is ranging over a positional param and then using .Get
within the range of just that first param to call for things like “class.”
So it’s different than the above example I just gave, since it’s about taking the single positional param (in this case a list of images, each with three key-value pairs), taking that single positional param and splitting it into an array of objects, and then accessing the key-value for each object within the array - hence the ideal shortcode in a markdown file, which includes multiple uses of the word “class”…
{{< fluid_img "class='class-1' src='image-1.jpg' alt='image 1 description',class='class-2' src='image-2.jpg' alt='image 2 description',class='class-3' src='image-3.jpg' alt='image 3 description'">}}
I tried the following just to test, which works to spit out each individual item within the array of objects…
{{ range $key, $val := split (.Get 0) ","}}
{{ range split $val " " }}
{{.}}<br>
{{end}}
{{end}}
But what @yoshiharuyamashita is looking for is something closer to this, I believe:
{{ range $key, $val := split (.Get 0) ","}}
{{ range split $val " " }}
{{.Get "class"}}<br>
{{end}}
{{end}}
Does that make sense?