Say I want to have a template somewhere which is multiline string:
I have some
text with ${placeholders}
in this and some ${different}
ones ${here} and ${there}
What would be my best way of replacing the placeholders with input from a user? Would here-documents be a good use?
Best Answer
Assuming [a] that no \<newline>, nor the characters
\
,$
, or`
are used in the multiline string (or they are properly quoted), a here-document (and variables) is your best option:If executed:
Of course, correctly playing with qouting, even one variable could do:
Both solutions could accept multiline variable placeholders.
[a]From the manual: