I'm fiddling around with scala's XML capabilities, trying to produce some xhtml form. Here's what I got:
class LoginForm {
var title = "Login"
var username = ""
def content =
<div class="login">
<h1>{this.title}</h1>
<input type="text" name="username" value="{this.username}" />
</div>
}
var f = new LoginForm
f.username = "foo"
f.content
When the code is run, the title is interpolated as expected, but the value of the input element is not. Why is this? And is there a way around that problem?
Okay, figured this one out by myself. The attribute quotes are added by scala itself, so we don't have to. So, the correct way would be this (note the missing quotes around the username interpolation):
<input type="text" name="username" value={this.username} />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With