score:7
Accepted answer
Actually I have never seen @if nor have I tried PlayFramework. But if is what I think it is, it seems that when you actually try to ask for letter it's already out of scope. What happens if you re-arrange the brackets as follows?
@for(col <- List.range(0,12)) {
<td>
@if(col % 2 == 0) {
@{val letter = someMap(col)
<div class="z@(letter)@(letter)s"></div>
}
}
</td>
}
score:0
The only way I got this working on Play Framework 2.8.x was with Scala's Range function:
@import scala.collection.immutable.Range
@for(col <- Range(0,12)) {
<td>
@if(col % 2 == 0) {
@{val letter = someMap(col)
<div class="z@(letter)@(letter)s"></div>
}
}
</td>
}
Source: stackoverflow.com
Related Query
- How to declare and access local variables in scala template in play framework?
- assigning to local variables in scala template in play framework
- How to get current day of the week and used it in scala template in Play framework
- How to prefill a dropdown using scala template and play framework
- How do I declare a variable in play template and access it in controller?
- How to use IntelliJ with Play Framework and Scala
- Which is best data access options available for Play framework with Scala and PostgreSQL?
- How do I get Intellij IDEA 12.0 to work with Play Framework 2.1.0 app and Scala 2.10.0?
- How to show images using Play framework and Scala in the view page
- How to pass optional parameter to scala template in play framework 2
- Scala Play framework 2.2 - How to get information about a users loginstatus in template
- How to create an instance of a model with the ebean framework and scala in Play 2.2
- Play framework Twirl template comparing javascript element and scala variable
- How to create OFormat from Format in scala and play framework
- Using play framework and scala how to display image path from database
- How to send email with attached file in scala and play framework (2.3.9) using activator?
- how to insert data into database using play framework and scala
- How to intercept and change exception in Scala Akka in play framework 2.4.6
- How to parse a trait and objects to JSON in Scala Play Framework
- How to check for 200 OK response status using Scala and Play Framework
- how to setup a for loop inside if statement with correct syntax Play framework Scala Template
- How to debug permgen memory errors for a project that uses sbt and play 2 framework in Scala
- Play and Scala: How to Declare val in view template
- How do I store a pointer to a template in scala Play Framework 2?
- Play framework 2.3.2: How to render List or Map in scala template
- how to write java code inside scala template in java play framework
- How to redirect http:// to http://www on Heroku using Play framework and Scala
- How to log user credentials when authentication fails with Scala Play Framework and Silhouette
- How to log user credentials when authentication fails with Scala Play Framework and Silhouette
- How do I replace Js Global Variables and handle scala variables in Play Framework?
More Query from same tag
- Akka Stream return object from Sink
- Scala type mismatch problem (expected Map, found scala.collection.mutable.HashMap)
- Confused by "Scala in Depth" Option example
- Scala List methods: `remove` and `sort`
- Why does spark write huge file into temporary local disk even without on-disk persist or checkpoint?
- Implementing value equality of functions
- type mismatch; found : Unit required: Array[org.apache.spark.sql.Dataset[org.apache.spark.sql.Row]]
- Scala : How to pass a class field into a method
- Return type with generic with bounds
- Scalatra stand-alone deployable cannot create assembly
- In Scala, is it possible to have a case class containing methods with identical names to fields?
- Partition a sequence of disjunctions in Scalaz
- How to partition Spark dataset using a field from Kafka input
- Functional way to create a union of all keys from a Seq of Maps in Scala
- Get value from external client database for a column value as a key in spark dataframes
- Why there can be only one implementation of a typeclass for any given type parameter?
- Can't init Scala Gradle project: -bash: gradle/gradle-5.2.1/bin/gradle: No such file or directory
- Scala Type mismatch when a generic type operates on the same generic type
- Partial Function of T to T for any T
- scala specialized general numeric operations
- Mixing pure and impure with Cats Effect
- How can I use memcached (Amazon elasticache) from both scala and rails simultaneously?
- Scala: How to apply the pattern matching function to a csv file which contains the below mentioned values
- What does it mean 'List(1, 2, 3)' in Scala?
- Interval merge using Spark Scala
- Scala, Erastothenes: Is there a straightforward way to replace a stream with an iteration?
- What is the difference between "class C extends A with B" and "class C extends B" when trait B extends trait A
- Spark Streaming - Accessing an array of custom case class objects in a Spark SQL dataframe
- Complex Scala Type Inference w/ Lambda Expressions
- Storing a LatLon class as GeoJSON using MongoDB / Morphia (Scala or Java)