Code within xml start tags


#1

I have some basic xml / html with embedded scala code e.g.

<tr><td>{ var1 }</td><td>{ var2 }</td></tr>

What I want to do is somthing similar but have the logic within the tag e.g.

<tr><td { if(var1==1) style="background-color:blue"; else style="background-color:red" } > {var_another} </td> ...

but it doesn’t play ball. There seems to be much on xml manipulation online but for something simple like the above, is there a quick solution?


#2

I think you have to take the style= part outside.

<td style={ if (var1 == 1) "background-color:blue" else "background-color:red" } > {var_another} </td>