I've seen that you can interpolate strings with fmt like so:
let msg = "hello"
echo fmt"{msg}\n"
But in my case, the interpolated string is quite long. I would prefer to assign said text to a variable and then the the interpolation later, like so:
let msg = "..... long text here {place_holder1}...."
echo interpolate(msg, var1, etc)
Is this possible?
Yes, see strutils.format.
strutils also comes with the % operator which can be used like:
let str = "$#, $#, $#"
let interp = str % ["One", "Two", "Three"]
echo(interp) # echos One, Two, Three
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With