I have a main template that captures a string:
@(captured: String)
.... other templating stuff
I have a sub template that wants to utilize @captured:
.... somewhere in this templating stuff we have:
@subTemplate(@captured) <- wants to use @captured
I try this and I get nothing but errors. Im sure this MUST be possible, so what am I doing wrong? Im sorry if this question is simple, I just dont know how to succinctly phrase it for Google.
You need to remove the trailing @ symbol on
capturedwhen it is being passed in as a variable.e.g
The reason why this is the case is because @ is a special symbol that tells Play that the template engine is about to do some computation, rather than just outputting HTML. In the case above, by calling the sub template, you have already started a computation (i.e used the @ symbol), so you do not use it again inside the parenthisis, because the compiler is already in computation mode.
This was exactly the same in the Play 1.x template engine.