im trying to populate a list in an html template using a prexisting module
@{Nav.list.map( l =>
l.id match {
case "Art" => { <li id="art"><span>Articles</span></li> }
case "Due" => { <li id="toggle"><a href="javascript:void(0)" title="Links"><span>Links</span></a>
<div id="drawer">
<div id="drawerContent" style="display:none;">
<ul>
<li><a href="#" title="link hover"><span>link title 2</span></a></li>
<li><a href="#" title="link hover"><span>link title 3</span></a></li>
<li><a href="#" title="link hover"><span>link title 4</span></a></li>
</ul>
</div>
</div>
</li> }
case _ => { <li id="@l.id"><a href="@l.href" title="@l.title"><span>@l.title</span></a></li> }
} )}
the @ isnt functioning as an escape character for the final case and instead just gets parsed as @l.id etc i originally did this with nested if else statements with very verbose brackets and that worked but wasnt very nice on the eyes, i think the formatter is having problems with nested scala constructs but im not sure.
i tried using for instead of map and tried enclosing and escaping the match construct, they compile but the issue still remains
I think the issue here is that you are in scala world when doing @{}, thus you can do the following in the last case:
case _ => <li id={l.id}><a href={l.href} title={l.title}><span>{l.title}</span></a></li>Alternatively I think you can do:
@Nav.list.map( l => ... )