Note that resources.FromString does not overwrite an existing file when ranging through the slice of commands or between rebuilds when running hugo server. That’s why I initially used now.UnixNano for the temporary file name.
When we use a hash value (md5) for the temporary file name, the code above does not do what we think it does when our slice of commands contains duplicate items. For example:
{{ $s := slice "add 5 1" "add 5 1" }}
When processing the second item, resources.ExecuteAsTemplate uses the resource created for the first item. But that’s OK because the expected result is the same.
I don’t think your reasoning is correct, which I think would be clear if you do add now.UnixNano 1 or something. The use of the MD5 leads to the reasource and the result of parsing the template getting cached, which is a good thing and what you want.