Skip to content

Navigation Menu

Sign in
Sign up

StringInterpolation not works well with Seq #347

Open

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>&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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      AltStyle によって変換されたページ (->オリジナル) /