I need to get an image within a Page bundle from a template (index.html) and I am having a hard time debugging the situation, could someone check if my reasoning is correct ?
This give me an error ``` Failed to render pages: render of "home" failed: "/Users/matthieu/apps/www.pilot.pm/layouts/index.html:198:56": execute of template failed: template: index.html:198:56: executing "main" at <$image.Resize>: nil pointer evaluating resource.Resource.Resize
So to debug I set this {{ printf "%#v" $image }}
Which gave me this inforamtion, which is an adress to a resource (am I right ?) &resources.resourceAdapter .... .....
Now that I am sure $image is a resource I should be able to call .resize isn’t it ?
Apart from that, it’s wrong (people with deeper knowledge correct me if I am wrong) to “assign” a variable twice. You use := to create a variable and then must use = to change it’s value/content.
@mhby
The above construct does not work because although you are using .GetPage to fetch that Page, you are not getting its resources because you are not within the Page context.
@davidsneighbour
Yes, you have a point about variable overwrites. It is always better to overwrite than re-assign the same variable However as far as I know re-assigning with := instead of overwriting with = shouldn’t cause a problem (unless we are talking about some huge project -then I don’t know-).