Resources.Get image gets NIL when i'm passing by params

I’m working with a list and i want to display an image in every element of the list. When i put the specific direction in the html fil it works, but i want to show diferents photos in every element, thats why i pass a parameter.

I get this error:

ERROR 2021/12/18 01:18:33 Rebuild failed:

ERROR 2021/12/18 01:18:33 Failed to render pages: render of "home" failed: execute of template failed: template: index.html:9:9: executing "index.html" at <partial "home.html" .>: 
error calling partial: "D:\Hugo\simpleIntro\layouts\partials\home.html:63:36": execute of template failed: template: partials/home.html:63:36: executing "partials/home.html" at <resources.Get>: error calling Get: CreateFile D:\Hugo\simpleIntro\assets\images\%!s(<nil>): The filename, directory name, or volume label syntax is 
incorrect.

My html file:

{{ if $data.team.index.list }}
      <div class="mt-8 grid grid-flow-row grid-cols-1 md:grid-cols-2 lg:grid-cols-2 gap-4 ">
        {{ range $data.team.index.list  }}
        <div class="max-w-md bg-white rounded-xl shadow-md overflow-hidden md:max-w-2xl">
          <div class="md:flex md:h-48">
            <div class="md:flex-shrink-0">             
              {{ $image := resources.Get (printf "images/%s" .Params.image_professor) }}
              {{ with $image }}
              <img class="h-48 w-full object-cover md:h-full md:w-48" src=" {{ $image.RelPermalink }} ">
              {{ end }}
            </div>
            <div class="p-8">
              <div class="uppercase tracking-wide text-sm text-indigo-500 font-semibold">{{ .title }}</div>
              <p class="block mt-1 text-lg leading-tight font-medium text-black">{{ .title }}</p>
              <p class="mt-2 text-gray-500">{{ .text }}</p>
            </div>
          </div>
        </div>
        {{end}}
      </div>
      {{else}}
      <div class="mt-4 text-xl text-center">Team does not exist</div>
      {{end}}

My TOML index file:

[[list]]
    title = "lorem"
    url = "/project1.md"
    image_professor = "angel.jpg"
    text = """
        Lorem ipsum dolor sit amet, consectetur adipisicing elit.
        Voluptatibus quia, nulla! Maiores et perferendis eaque,
        exercitationem praesentium nihil. 
    """
[[list]]
    title = "lorem"
    url = "/project1.md"
    image_professor = "angel.jpg"
    text = """
        Lorem ipsum dolor sit amet, consectetur adipisicing elit.
        Voluptatibus quia, nulla! Maiores et perferendis eaque,
        exercitationem praesentium nihil.
    """
[[list]]
    title = "lorem"
    url = "/project1.md"
    image_professor = "angel.jpg"
    text = """
        Lorem ipsum dolor sit amet, consectetur adipisicing elit.
        Voluptatibus quia, nulla! Maiores et perferendis eaque,
        exercitationem praesentium nihil.
    """

i don’t know if is bug or i am doing something wrong with the syntax. If anyone got another better solution i will grateful.

You already range inside $data.team.index.list context. You call it directly using .image_professor.

.Params only used to grab data from Frontmatter

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.