In brief
string.Template uses placeholders such as $name for text substitution. substitute() expects the required values; safe_substitute() can leave unresolved placeholders in the result.
Useful to know
string.Template uses placeholders such as $name for text substitution. substitute() expects the required values; safe_substitute() can leave unresolved placeholders in the result. [1]
Here, safe does not mean safe HTML or SQL. It describes missing-value behaviour, not protection for every later use. Choose escaping or parameterization separately according to where the resulting text will be used.
Sources
For further detail and to check the information: