Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StringFrag.toString doesn't behave as expected #191

Open
adridadou opened this issue Jun 12, 2019 · 7 comments
Open

StringFrag.toString doesn't behave as expected #191

adridadou opened this issue Jun 12, 2019 · 7 comments

Comments

@adridadou
Copy link

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)"

@Bathtor
Copy link

Bathtor commented Jun 12, 2019

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.

@lihaoyi
Copy link
Member

lihaoyi commented Jun 12, 2019

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

@adridadou
Copy link
Author

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

@adridadou
Copy link
Author

.toString doesn't produce HTML for StringFrag though.

@adridadou
Copy link
Author

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.

@lihaoyi
Copy link
Member

lihaoyi commented Jun 12, 2019

Changing the documentation to tell people to use .render seems fine by me

@adridadou
Copy link
Author

sounds good to me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants