In the controller we are creating a string which shall be interpreted as Html when the page is being rendered. Whenever the string contains scala/twirl code starting with "@" it leads to the page not rendering it correctly/at all.
Controller:
// render method
return ok(Html.apply(testButton()), testForm);
public String testButton() throws SQLException {
result = "<input type='radio' id='@TestForm(\"TestID\").id'
name='@TestForm(\"TestID\").name' value='5' >" + "Test";
return result;
}
Scala.html:
@(buttons: Html)(TestForm: Form[TestForm])
@buttons
How it should look:
<input type='radio' id='TestID' name='TestID' value=5 >test
How it looks:
<input type='radio' id='@TestForm("TestID").id' name='@TestForm("TestID").name' value='5' >test
We also tested this with other examples. The problem really seems to be the @. Maybe the parser parses the site once, replaces the @button with our code, but doesn't parse that after it. We also tried escaping the @ with different methods(@@, \@, no @), but it always ended up in plain text afterwards.
What is the easiest method to get an @ inside another @ to render?