title: Can't use template variable of type string where a string literal would be allowed?
body: <p>It seems I cannot invoke <code>.Resources.GetMatch</code> with a template variable of type string, though I can invoke it with a string literal.  I know I can invoke it with <code>.</code> in a <code>with</code> block, but would like to know why this code doesn't work.</p>
  <p>Main template invokes partial with a second argument stuffed into <code>.Scratch</code>:</p>
  <pre><code>single.html
  ...html
  &lt;div &gt;
      &lt;p&gt;Feature image:&lt;/p&gt;
      {{ .Scratch.Set &quot;arg1&quot; .Params.image}}
      {{ partial &quot;local-image.html&quot; . }}
      &lt;p&gt;End feature image:&lt;/p&gt;
    &lt;/div&gt;
  </code></pre>
  <p>Partial tries to retrieve the scratch argument and retrieve the corresponding page resource object:</p>
  <pre class="lang-html prettyprint-override"><code>{{ $srcPath := (.Scratch.Get &quot;arg1&quot;) }}
  {{ printf &quot;debug type %T, value %#v&quot; $srcPath $srcPath}}
  {{ .Resources.GetMatch $srcPath }}
  </code></pre>
  <p>Hugo build error:</p>
  <pre><code>ERROR 2020/11/24 00:28:34 Failed to render pages: render of &quot;page&quot; failed: 
  execute of template failed: template: _default/single.html:67:7: executing &quot;main&quot; at &lt;partial &quot;local-image.html&quot; .&gt;: 
  error calling partial: &quot;C:\Users\xyz\src\hugo-blog\themes\hugo-theme-bootstrap4-blog\layouts\partials\local-image.html:5:23&quot;: execute of template failed: 
  template: partials/local-image.html:5:23: executing &quot;partials/local-image.html&quot; at &lt;$srcPath&gt;: 
  invalid value; expected string
  </code></pre>
  <p>If I comment out the failing line so I can see the preceeding debug output,</p>
  <pre class="lang-html prettyprint-override"><code>{{ $srcPath := (.Scratch.Get &quot;arg1&quot;) }}
  {{ printf &quot;debug type %T, value %#v&quot; $srcPath $srcPath}}
  {{/* .Resources.GetMatch $srcPath */}}
  </code></pre>
  <p>Build succeeds, and page renders this:</p>
  <pre><code>Feature image:
  
  debug type string, value &quot;IMG_20200404_164934.jpg&quot;
  End feature image:
  </code></pre>
  <p>So the puzzle here is why <code>.Resources.GetMatch</code> complains about <code>$srcPath</code> when the latter is demonstrably of type <code>string</code>.</p>
  <p>(Yes, I know it would be more colloquial to pass multiple arguments into a partial in a <code>dict</code>, but I was running into similar errors extracting values out in the partial, so came up with the above more concise example.)</p>