I know little about SVG but I'm trying to make the text parameter variable, so I could iterate and create SVG Markup's which vary solely by (variable) text. This is what I can do (borrowed from the site whose API I'm using)
'<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg">' +
'<rect stroke="black" fill="${FILL}" x="1" y="1" width="22" height="22" />' +
'<text x="12" y="18" font-size="12pt" font-family="Arial" font-weight="bold" ' +
'text-anchor="middle" fill="${STROKE}" >hello world
</text></svg>'
But this is what I would like (or something that works like it):
'<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg">' +
'<rect stroke="black" fill="${FILL}" x="1" y="1" width="22" height="22" />' +
'<text x="12" y="18" font-size="12pt" font-family="Arial" font-weight="bold" ' +
'text-anchor="middle" fill="${STROKE}" >"${TEXT}"</text></svg>'
so I can dynamically change the text.
You actually can use
${TEXT}
, and it does work (except for IE).The name of this is template literal:
However, for this to work, you should have enclosed the whole string with back-ticks (`).
Here is a working demo using your string (with little changes):
Ok I figured it out; in retrospect, it was kind of a stupid question