Just use @main(param)
instead of @main(@param)
playframework2 template, why the simple string is ok while the parameter with string get compile error
-
29-06-2023 - |
Question
If my code is:
@(param: String)
@main("hello world") {
@slides("sssdfdes")
<div class="list-group">
</div>
}
It works, @main is my another template. But if I want to do:
@(param: String)
@main(@param) {
@slides("sssdfdes")
<div class="list-group">
</div>
}
the compile get me error:
[info] Set current project to slickplay (in build file:/C:/testprojects/slickpla
y/)
[info] Compiling 1 Scala source to C:\testprojects\slickplay\target\scala-2.10\c
lasses...
[error] C:\testprojects\slickplay\app\views\shopmain.scala.html:6: illegal start
of simple expression
[error] @main(@param) {
[error] ^
[error] C:\testprojects\slickplay\app\views\shopmain.scala.html:15: ')' expected
but '}' found.
[error] two errors found
[error] (compile:compile) Compilation failed
[error] Total time: 3 s, completed 08/04/2014 8:24:11 PM
How to passing variable string in scala template in this situation?
Solution
OTHER TIPS
It is because u are using '@' multiple times in a single row,
Just use @main(param) instead of @main(@param)
answer is given by @serejja above
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow