Display the order value of a record

Hello. I have a big section. This is my code

				{{ $paginator := .Paginate (where .Pages "Type" "cases") }}
				{{ range $k, $v := $paginator.Pages }}
					{{ .Render "cases_section.li" }}
				{{ end }}					
{{ partial "pagination" . }}

And is it possible to pass the value to the cases_section.li subpattern?

Unfortunately, it’s not possible to pass anything to the .Render.

I came up with a hack that works really well. Example …

Hope this helps.

You can pass it via .Scratch. But there may or may not be concurrency issues.

Yes, I had inconsistent results due to concurrency… @regis had a thread on Render + Scratch + concurrency in this forum may be a year ago? (man, time flies).

Update: OK, not a year ago, ~6 months :slight_smile:

There was, systematically.
In my case I was using scratch to assign a layout string (list or single) in order to test it and modify the html structure accordingly. But as Bep pointed, this would break during build.

.Render is awesome and yet I find myself too often putting it aside because of the impossibility to assign it a custom set of variables or context. Using it despite this will almost systematically force me to copy/paste two quasi identical template files.

I often pondered suggesting to enhance .Render with the possibility of passing a context as argument in the line of partial… But this would mean introducing a way to retrieve this custom context vs the default page context, be it via a method (like .Get) or a reserved key (.Context, .Template etc…).