# How can I use printf to form the name of a partial to call?

How can I use printf to form the name of a partial to call?

I have the code:

``````{{ partial (printf `weight/%s.html` .Params.grossweight) . }}
``````

It trows an error:

``````error calling partial: partial "weight/2.html" not found
``````

The existing partial’s name is weight2.html

How to get rid of that slash?? If I just remove it, the error message is:

``````error calling partial: partial "weight%!s(<nil>).html" not found
``````

which is totally understandable. However I can’t find the way to separate %s.

`{{ partial (printf "weight%s.html" .Params.grossweight) . }}`

2 Likes

Thank you, bep! It works!!! But I’m puzzled - I think I tried everything, starting with this syntax!

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