scalatags
scalatags copied to clipboard
StringFrag.toString doesn't behave as expected
if you use .toString to render the tags (instead of .render) StringFrag doesn't behave as expected.
I.e. StringFrag("hello world").toString shouldBe "hello world" but actually StringFrag("hello world").toString is "StringFrag(hello world)"
Actually, I would prefer it if that were the expected behaviour, i.e. render produces HTML or DOM output, while toString tells you what DSL tree you built for debugging purposes.
But you are right, right now the documentation states that toString produces HTML.
Yeah let's just make its .toString produce HTML. Swapping out HTML v.s. DSL output would be a big breaking change which wouldn't get caught by the compiler. The small amount of elegance gained doesn't seem worth the transitional pain
If that's the case, I would then change the documentation to use .render instead of .toString
Otherwise it's confusing.
The thing is that .toString is implemented as some sort of .render for ALMOST all the tags, but not this one
.toString doesn't produce HTML for StringFrag though.
the only change I'm proposing here is to have StringFrag returning its content rather than a default toString implementation because I am pretty sure this is not what ppl are expecting there.
Changing the documentation to tell people to use .render seems fine by me
sounds good to me!