Questions tagged [scala-template]

71 questions
2
votes
2 answers

Reusable functions between templates in Play Framework templates

In Play Framework inside of a template I can define functions like that: @title(text: String) = @{ text.split(' ').map(_.capitalize).mkString(" ") }

@title("hello world")

Can I define such function in separate file and make it reusable…
szymond
  • 1,311
  • 2
  • 19
  • 41
2
votes
1 answer

Play2.2 Java - Prevent escaping on Javascript template

Description: I'm trying to initialize a JSON object into my javascript template. View: views.tasks.task.js @() @import play.libs.Json @import enums.TaskType ... var taskTypes = @Html(@Json.stringify(TaskType.valuesJson())); Model: TaskType public…
2
votes
3 answers

Scala templates import reusable blocks (Play2)

I'm using Play framework 2.2.4 and Scala templates. I have created base Scala template with many code blocks, which I want to use in multiple views. Something like: base.scala.html @() @display(product: Product) = { @product.name…
Michał Jurczuk
  • 3,728
  • 4
  • 32
  • 56
2
votes
4 answers

flash/session not found after migration to 2.3

I have such error in scala template: not found: value flash 19 @if(flash.contains("bladLogowania")) { 20

21 @flash.get("bladLogowania") 22

} I have read that there is some change but I am not sure…
user3789309
  • 31
  • 1
  • 3
2
votes
1 answer

HTML attribute in Scala Template

I am a Java developer who recently started to learn about the Play Framework. I have been trying to get the below template working but cant seem to get it. I have got the following in my Scala template @navItem(label: String, link1: String) = { …
aniruddhc
  • 320
  • 1
  • 3
  • 15
2
votes
1 answer

Playframework POST a list to controller

All I am trying to achieve is this Sample app : ~\play-2.1.0\samples\java\forms Updated Latest Code : my question.scala.html looks like : @(questionForm: Form[Question]) @import helper._ @import helper.twitterBootstrap._ @answerField(field:…
Suave Nti
  • 3,721
  • 11
  • 54
  • 78
1
vote
1 answer

Scala Templates: Map a String to a Template

I use Scalate for templating. Usually it goes this way: Template: Hello {{name}} Parameters: `Map("name" -> "Peter") Result: Hello Peter Is there a way to get the Parameter Map as Result? Template: Hello {{name}} Request: Hello…
pme
  • 14,156
  • 3
  • 52
  • 95
1
vote
2 answers

Scala/Java template list iteration and concatenation of string

I want to iterate over a list of strings, concatenate them with the suffix/prefix "" and if it's not the last entry of the list append a comma at end. Wanted Output example: "circle","cube","banana" My first try is the following…
Yeti
  • 63
  • 7
1
vote
0 answers

How to handle dynamic time row(form) insertion in scala-template play2.4

Suppose that i have a scala template that take single userName and age as input and submit that we can simply handle binding and passing form of class Class FormExample { String userName; int age; } Now suppose user want one more button like…
visingh
  • 233
  • 3
  • 17
1
vote
1 answer

switching between RTL and LTR in play framework

we are developing a web site that we need to support both LTR and RTL. we find that the best way is to change in CSSs(i.e. CSS for LTR and another to RTL). and that worked fine, the question is how to decide wether the language needs LTR or RTL. I…
1
vote
1 answer

Play framework JavaScript function as scala template parameter

I want to reuse a javascript function using a scala template so I would only have to pass a different success/failure function, but I don't seem to be able to able to pass a javascript function to a scala template. Please note I'm veeeeerry new to…
1
vote
0 answers

Play! upgrade error: ')' expected but '}' found

Just upgraded our project to Play! 2.2.1. After fixing dependencies, checking code, and fixing all initial compiler errors I went to launch the project and got the following: ')' expected but '}' found. It occurs in 3 "view" files pointing to the…
crockpotveggies
  • 12,682
  • 12
  • 70
  • 140
1
vote
1 answer

Play Framework 2 - Scala template: How to call a specific method on a generic object?

I am using Play Framework 2.1.5 in a Java application. I've got a view component that takes a list of generic objects as a parameter. In this component, I want to iterate on the list and get some properties of each element. This would look like…
1
vote
2 answers

Deadbolt Restrictions Annotation missing - Play 2.1.1, Deadbolt 2.1

I just noticed that the @Restrictions Annotation is missing in Deadbolt 2.2 and also in the deadbolt-2.1 version. In the example and the documentation it is explained (http://deadbolt-2-java.herokuapp.com/#controller-Restrictions). Here it exists…
1
vote
1 answer

How to increment a variable in template without loop -- Play 2.1.1, Java

I would like to generate ID's for an HTML list. The list is generated dynamically from the database. I cant use a for loop or the list.zipWithIndex function because my logic contains a few loops for the generation of the list already, in which the…