--
You received this message because you are subscribed to the Google Groups "Play Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to play-framework+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/play-framework/67238056-3ab3-4170-994d-523a6a0c6ad0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
I am not aware of that ever being a feature. Did you see it documented somewhere? The parser was improved in twirl 1.3 which may have eliminated weird edge cases like this.You can define reusable values using @defining though: https://www.playframework.com/documentation/2.6.x/ScalaTemplates#Declaring-reusable-valuesYou can also use var within a block of code:@{var x = 1// do something with x anywhere in this block}or define reusable blocks:@x = { "foo" }x is @xTemplates are meant to be stateless so it really doesn't make sense to declare a variable within a template.
On Sat, May 13, 2017 at 7:34 AM, David <massar...@gmail.com> wrote:
I might be missing something but how does one declare a variable in a Play 2.6 template?Play 2.5 allows things like:@import java.math.BigInteger; var i=0After upgrading to 2.6, I get the following compilation error:[error] /project/app/views/repositoryLister.scala.html:2: expected class or object definition[error] @import java.math.BigInteger; var i: BigInteger = 0[error] ^[error] one error found[error] (compile:compileIncremental) Compilation failed
--
You received this message because you are subscribed to the Google Groups "Play Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to play-framewor...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/play-framework/67238056-3ab3-4170-994d-523a6a0c6ad0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to play-framework+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/play-framework/cf215ba3-79d7-420c-84d5-53ea6aa4fdc7%40googlegroups.com.
@import play.api.libs.json.JsObject
@(reps: Seq[JsObject])
@import play.api.libs.json.JsObject
@import java.math.BigInteger; var i=0
@(reps: Seq[JsObject])
<table>
@for(rep <- reps) {
@(i+=1)
@if((i % 2) == 0) { <tr class="even"> } else { <tr> }
<td>@{(rep \ "_id").as[String]}</td>
@import play.api.libs.json.JsObject
@(reps: Seq[JsObject])
<table>
@for( i <- 0 to (reps.length - 1) ) {
@if((i % 2) == 0) { <tr class="even"> } else { <tr> }
<td>@{(reps(i) \ "_id").as[String]}</td>
To view this discussion on the web visit https://groups.google.com/d/msgid/play-framework/cf215ba3-79d7-420c-84d5-53ea6aa4fdc7%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to play-framework+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/play-framework/365a882e-ab6c-4a82-8bde-c016a6f97f7c%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/play-framework/365a882e-ab6c-4a82-8bde-c016a6f97f7c%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to play-framework+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/play-framework/8da41650-ee41-4980-aadf-fa95368bc5a7%40googlegroups.com.