The Play framework Scala template engine repackaged for stand-alone use.
Questions tagged [twirl]
147 questions
0
votes
1 answer
Play framework - calling view from another view with parameters
I'm trying to call a main layout from a view (just like in docs ) but I get the error:
[error] C:\Users\Marco\Documents\Devel\Java\DroversWeb\app\views\device\list.sca
la.html:1: too many arguments for method apply:…

Marco
- 1
- 3
0
votes
1 answer
How to write rendered template output to file?
I'm using Twirl in a non-play sbt project, and defined a template:
hello.scala.html
Welcome hello world
It generates a Scala file containing the following code: package html import play.twirl.api._ import…
Freewind
- 193,756
- 157
- 432
- 708
0
votes
2 answers
Undesirable syntax in Play framework templates
I am using Play 2.3.7 Java, and I am trying to render templates. I can get it to work, but only by using really ugly syntax. What I have that works so far is right here: https://gist.github.com/aaron235/c21866dd7bff0ba3fc0c
Clearly, having a bunch…

user3140645
- 15
- 5
0
votes
1 answer
Twirl: tags/views with optional content
I want to create a tag with optional content... Let's say that I have a tag:
app/views/tags/part.scala.html:
@(param: String)(content: Html = null)
@if(content == null) {
@param: Your tag has no content...
} else {
@param: @content
}
And…

biesior
- 55,576
- 10
- 125
- 182
0
votes
1 answer
Pass reference to a template class in Play2 framework template engine
I have a field.scala.html that should take a control as input and render it.
Right now I do like this:
@field("shop", "name", true) { (modelName, fieldName, required) =>
@textInput(modelName, fieldName, required)
}
But I would like to do it like…

Anton Kuzmin
- 821
- 1
- 10
- 26
0
votes
1 answer
How to change the location of twirl templates for integration tests?
I'm trying to use twirl as part of my integration tests.
My integration tests have an HTTP simplicator that mimics a real world service. To implement this simplicator in the tests, I'm using spray-can embedded HTTP server which needs to spit out…

talkol
- 12,564
- 11
- 54
- 64
-1
votes
1 answer
I am getting error in this Python code, how can I debug it?
I tried twirl transformation on image in Python. But not getting the expected output. All the solutions on the internet are in C#.
import cv2
import math
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
img =…

Sadia_30
- 11
- 1
-1
votes
1 answer
Play! Framework - return multiple list to template
I have 3 classes and I wanna return 3 lists to template which use in Form
my db is MongoDB
def addCourse = Action.async {implicit request =>
val teacherCollection = db.collection[BSONCollection]("Teacher")
val courseColl =…

roohix
- 11
- 4
-2
votes
1 answer
Unable to render a for loop in Twirl
In a twirl template I'm trying to render a loop of strings and the current code is giving me code errors. I'm sure it's a small detail that I'm missing...
This is my template...
@(title: String)(content: Html)
…

Emmanuel Henri
- 153
- 3
- 27
-2
votes
1 answer
Scala template how to loop over two lists simultaneously
i have two lists
cards=List[Card]
paymentMode=List[String]
i want to loop over them simultaneously in Twirl template engine (Play Framework)
i tried
(cards zip paymentMode).map{ case (card, p) =>
and when i call @card i got "not found: value…

Ameni Gaaloul
- 43
- 5
-2
votes
1 answer
Dynamic list of urls in Twirl/Play
I'm trying to create a dynamic list of URLs in Twirl template with Play with no luck. I can't seem to map over a collection to create list of URLs for some reason. This is what I have:
@casesCollection.map(e => {

maloney
- 1,633
- 3
- 26
- 49
-5
votes
1 answer
Scala - declare a Java List that can hold anything
In Scala, how do I declare a Java List that can hold anything?
List[Object] gets upset if I try and put a tuple in it, Scala errors says
type mismatch; found : java.util.List[Triple[Integer,Integer, Integer]] required:
java.util.List[Object]…

bharal
- 15,461
- 36
- 117
- 195