I know about this and this, but the answers are very strange, and in any case, I am looking to understand why this particular approach does not work:
@myPackage.views.html.ol(
{
Hello
}, {
World
}
)
myPackage.views.html.ol.scala.html
@(ol:Html*)
<ol>
@for(li <- ol) {
<li>
(hi)
<span class="li-body">@li</span>
</li>
}
</ol>
Error:
not found: value Hello
I must lack fundamental understanding about the rules of the template engine, because this seems intuitively correct to me.
estimatic's answer was correct.
Of what he presented, I would probably have used the
@html1 = ...
solution, but I found something else, which I hope will benefit some future reader.HtmlVarArgs.scala
ol.scala.html
And then I can use it in a template as follows:
The
@
character marks the beginning of a dynamic statement, so you are no longer in template syntax. It's trying to interpret the arguments to theol()
function as straight Scala/Java code, not the template syntax.It depends on what exactly you're trying to do, but here are two ways to do it. You could probably also use the
@defining
helper.Another way is to define the Html blocks at the beginning of your view.