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

StringInterpolation not works well with Seq #347

Open
clouds56 opened this issue Jun 11, 2020 · 0 comments
Open

StringInterpolation not works well with Seq #347

clouds56 opened this issue Jun 11, 2020 · 0 comments
Labels

Comments

@clouds56
Copy link

import play.twirl.api.StringInterpolation
val test_seq = Seq(10,20,30)
def test_div(i: Int) = html"<div>$i</div>"
html"""
<ul>
  <li>${test_div(-1)}</li>
  ${test_seq.map(i => <li>{test_div(i)}</li>)}
</ul>
"""

outputs

<ul>
  <li><div>-1</div></li>
  <li>&lt;div&gt;10&lt;/div&gt;</li><li>&lt;div&gt;20&lt;/div&gt;</li><li>&lt;div&gt;30&lt;/div&gt;</li>
</ul>

While I expects

<ul>
  <li><div>-1</div></li>
  <li><div>10</div></li><li><div>20</div></li><li><div>30</div></li>
</ul>

I know I can do this using

val test_seq = Seq(10,20,30)
def test_div(i: Int) = html"<div>$i</div>"
html"""
<ul>
  <li>${test_div(-1)}</li>
  ${test_seq.map(i => html"<li>${test_div(i)}</li>")}
</ul>
"""

but I hope we could have it done without nested quoting

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

No branches or pull requests

1 participant