The Play framework Scala template engine repackaged for stand-alone use.
Questions tagged [twirl]
146 questions
0
votes
2 answers
Playframework: how change the value of a twirl parameters without reload the entire page?
Supose I have a view that receive a list of things like that:
@(notices: Seq[Notice])
@for( not <- notices) {
not.title
}
....
and I have a method in a controller that its call by ajax and changes the values of the list. I know that…
![](../../users/profiles/5846870.webp)
Yohanna Lisnichuk
- 81
- 4
0
votes
1 answer
How to render java.util.Collection using Playframework template engine?
I just want to render a simple list. I followed official documentation but IntelliJ is showing an error. This is the code to display a ul list:
@import java.util
@(products: util.Collection[String])
-
@for(product <- products)
{
…
![](../../users/profiles/4408364.webp)
Prakash Pandey
- 2,238
- 2
- 26
- 52
0
votes
1 answer
Playframework -> Twirl scala showing simple form
I have spent 3 days 48 hours trying to show simple login form. It is me being stupid or play being complicated.
Anyway I am getting error:
[error] login.scala.html:16: Expected ')' but found 'EOF'
[error] }
[error] ^
[error]…
![](../../users/profiles/6196188.webp)
Vladimir
- 23
- 3
0
votes
1 answer
Playframework 2.x (Scala): Passing a Twirl/HTML code from a controller's function to the view
My Aim: Learn the limitations (if any) on parameters that I can send from the controller to view. Right now, I'm checking if I can send any Twirl's keyword (e.g., @, @for, etc.) from the controller function to the view, and then reload a part of the…
![](../../users/profiles/3848320.webp)
o-0
- 1,630
- 12
- 27
0
votes
2 answers
How do you create a Scala collection of content in a Play template?
I'm sure I'm missing the obvious but is there a way to create a collection of Html objects to pass to a Play template like @(title: String)(content: Seq(Html))? I am trying to dynamically generate a group of tab pages where each Html object is the…
![](../../users/profiles/3047277.webp)
geeforce
- 15
- 3
0
votes
1 answer
Play Framework / Twirl Dynamically include templates
Use case:
I have a route handling all requests at host:port/p route looks like the following:
GET /p/*path controllers.Application.p(path: String)
The p method gets some data and passes it right through to the view p:
return…
![](../../users/profiles/1350243.webp)
Brian G
- 185
- 1
- 9
0
votes
1 answer
How to add composite view like HashMap to twirl in playframework 2.4.x
I want to add a HashMap Object contains many different object(s) to the twirl template, because I do not like adding one by one as parameter to the twirl, it breaks the rule with design patterns.
the normal style:
views.html.index.render(object1,…
![](../../users/profiles/5783778.webp)
nikkofu
- 15
- 3
0
votes
1 answer
playframework with Twirl views not found: value
i pass a lot of time trying to solve very simple problem render à string or(List) from controller to view using playframework java and Twirl, my code here
in my controller
public Result list(){
//List todo =…
![](../../users/profiles/5308487.webp)
A.khalifa
- 1,974
- 3
- 20
- 35
0
votes
2 answers
create List inside twirl template
Usually I create all the stuff like that:
@(courses: List[models.Course])
Then I pass the List from the controller into the view from the render() method.
but this is some kind of special case, It's actually a partial and I would have to add the…
![](../../users/profiles/3101819.webp)
AME
- 2,092
- 5
- 17
- 36
0
votes
1 answer
Moving PlayFramework 2.4.x View Templates into a specific Package
I'm on IntelliJ 2.4.x and I'm trying to move the Twirl view template into a specific package (not the default package views.html). The reason for this is I have a sub project and I'd like to avoid clashing view names by namespacing the two sets of…
![](../../users/profiles/83960.webp)
ronaldwidha
- 1,325
- 1
- 12
- 24
0
votes
0 answers
Play 2.4.x -- what are the most efficient type of Objects to place in a @Twirl template?
You can place many things inside a @Twirl template and obviously something is concatenating all of those things into a final output String (Html)
My question is are there any specific Object types (say something like StringBuilder) that are easier…
![](../../users/profiles/2162886.webp)
Techmag
- 1,293
- 11
- 21
0
votes
1 answer
Passing a Call without the Params to a Twirl template
In Play Framework (v 2.3.7) (scala 2.11.5) I wish to pass a Call to a twirl template but I won't be able to calculate the params until after the template loads.
The use case is pagination on a table (with constraints and user defined search…
![](../../users/profiles/2162886.webp)
Techmag
- 1,293
- 11
- 21
0
votes
1 answer
Using scala template code blocks and values as argument to template call (Play Framework)
I've tried to use both reusable code blocks and reusable values as argument to a function call (another template), but always end up in a compilation error: "illegal start of simple expression".
Let's say I have the header template, which takes a…
![](../../users/profiles/568053.webp)
Blackbird
- 2,288
- 4
- 23
- 39
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:…
![](../../users/profiles/4507977.webp)
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…![](../../users/profiles/342235.webp)
Freewind
- 177,284
- 143
- 381
- 649