I think this follows from the representation of styles (and other boxes) in strings.
For example, this:
is really represented like this in a string:
template="a \!\(\*\nStyleBox[\"``\",\nFontColor->RGBColor[1,0,0]]\) and a ``"
Then either with StringForm
or StringTemplate
we get
In[10]:= StringTemplate[template]["foo", "bar"]
Out[10]= "a \!\(\*StyleBox[\"foo\",\nFontColor->RGBColor[1, 0, 0]]\) and a bar"
It's just plain substitution.
EDIT: This view also gives ideas on how to break substitution:
It appears that there is no special support for styling, it's all a side effect of how style boxes are encoded in strings.