playframework / playframework/twirl
StringInterpolation not works well with Seq
Open
Nobody has claimed this yet.
- Dominant language
- Scala
- Stars
- 561
- Forks
- 118
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 29
Description
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><div>10</div></li><li><div>20</div></li><li><div>30</div></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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the StringInterpolation entry point and reproduce the provided Seq interpolation example. Compare the current escaped output with the expected unescaped HTML for mapped template fragments; done means the example works without nested quoting while preserving the existing direct interpolation behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- scala
- Domain
- web-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100