I want to split my html content into different partials, so can combine them easily in different pages. I tried to code like this:
object App extends JSApp {
@dom def title2() = {
<!-- Title 2 -->
<h2>Title 2</h2>
<!-- End Title 2 -->
}
@dom def render() = {
<h1>Title 1</h1>
{ title2.bind }
<h3>Title 3</h3>
}
@JSExport def main(): Unit = {
dom.render(document.getElementById("app"), render)
}
}
then get compiling error, saying:
App.scala:23: org.scalajs.dom.html.Heading does not take parameters
[error] { title2.bind }
[error] ^
[error] one error found
[error] (compile:compileIncremental) Compilation failed
then I add one empty line between title1 and title2
@dom def render() = {
<h1>Title 1</h1>
{ title2.bind }
<h3>Title 3</h3>
}
Compile success with one warning:
App.scala:24: a pure expression does nothing in statement position; multiline expressions might require enclosing parentheses
[warn] { title2.bind }
[warn] ^
[warn] one warning found
When I open the html file, I find that title1 and title2 are both missing, there is only title3 on the page.
I am new to scala and Binding.scala, and don't know why this happens.
You can try to test on ScalaFiddle