Closed sasha2048 closed 3 years ago
The simplest solution would be to create add one more string interpolator
the use of $
to introduce interpolated items is built-in at the language level, as per https://docs.scala-lang.org/overviews/core/string-interpolation.html , so I believe you are asking for a design change to how string interpolation in general works, not merely asking for "one more string interpolator"
also, Scala's XML syntax has been considered legacy for a long time now and is well into the process of being phased out entirely, so I expect you would need a stronger design justification for this than just "unify with XML"
(string interpolation was added to Scala some years after XML support was added; if string interpolation had existed first, language-level XML support would probably never have been added at all)
@SethTisue, thanks for explanation.
On the one hand, I liked {name}
style more than $name
and/or ${name}
. On the other hand, I also like the idea to phase out XML support, because I feel that its syntax (in Scala) is not fully consistent per se (I even was thinking about creating a separate feature request related to that).
Probably I should close this request.
P.S. Do you know — is there another feature allowing to generate XML quickly (something quicker than just calling scala.xml.Elem constructors directly, which can be used instead of that going-to-be-phased-out language-level XML support)?
There's https://github.com/lampepfl/xml-interpolator/ but it's in need of a maintainer.
Currently:
$
(or both prepend with$
and surround with{…}
):s"Item count is $itemCount"
(ors"Item count is ${itemCount}"
).{…}
:<span>Item count is {itemCount}</span>
.The following, of course, doesn't work:
s"Item count is {itemCount}"
,<span>Item count is $itemCount</span>
.The simplest solution would be to create add one more string interpolator — say,
b"Item count is {itemCount}"
. It will have the following benefits:s"$value and then ${value+1}"
→b"{value} and then {value + 1}"
(or, if you always use${…}
, even for simple expressions, then{…}
is just cleaner).