The Play framework Scala template engine repackaged for stand-alone use.
Questions tagged [twirl]
146 questions
3
votes
1 answer
How to get html, css and js all in one get with akka http?
I'm trying to serve my html, css and js with akka http:
path("") {
get {
getFromResourceDirectory("home")
complete(HttpEntity(ContentTypes.`text/html(UTF-8)`, home.render().toString()))
}
}
home.render() is a twirl template that…
![](../../users/profiles/4031815.webp)
CommonSenseCode
- 18,848
- 28
- 112
- 163
3
votes
1 answer
Play framework 2.5 scala i18n
I've followed the documentation in https://www.playframework.com/documentation/2.5.x/ScalaI18N and translations inside controllers works fine.
However, I need translations in Twirl templates.
With implicit messages and/or using…
![](../../users/profiles/353098.webp)
Henrique Gonçalves
- 1,472
- 3
- 17
- 27
3
votes
1 answer
Play Framework - how to walk tree of JsonNode in view?
Hi I am trying to display nested JSON data in my view, similar to how it appears in the Advanced REST Client when you get a response from an API.
I found this question which basically asks the same thing I am asking; however, I want to display the…
![](../../users/profiles/1092403.webp)
KJ50
- 706
- 1
- 10
- 27
3
votes
1 answer
Can't concatenate play.twirl.api.Html objects with play 2.3
I am trying to migrate a rather large project from play framework 2.2 to 2.3. In the project we have some helpers that do something like this:
import play.api.templates.Html;
...
private object HtmlHelper {
...
// Given a sequence of Htmls,…
![](../../users/profiles/1612524.webp)
Paul Sachs
- 665
- 2
- 8
- 21
3
votes
2 answers
Load twirl template dynamically
In my Scala project I use Twirl template engine. Template files structure is duplicated for russian and english languages so for example I have the following two paths: en.Send.txt.MonoEnsure and ru.Send.txt.MonoEnsure
In my code I want to be able…
![](../../users/profiles/179746.webp)
src091
- 2,479
- 5
- 35
- 68
2
votes
1 answer
Integrating Play Framework and Twirl Templates with Webpack and React
I am currently migrating a Play Framework application with a view composed entirely of Twirl templates into one with a view composed of a mix of Twirl and React. I have written a PlayRunHook to integrate Webpack with Play's build process, and the…
![](../../users/profiles/1347281.webp)
Vidya
- 28,359
- 6
- 36
- 63
2
votes
1 answer
javascript variable not defined when inline
Background:
I am using PlayFramework to create a webapp (workflow) system which uses the Twirl template engine (scala based) to create my views.
Problem:
I need to store JavaScript variables inside of my template (which renders HTML), where in a…
![](../../users/profiles/4628115.webp)
CybeX
- 1,653
- 27
- 77
2
votes
1 answer
Import part of a file in Twirl [PlayFramework]
I'm using PlayFramework and Twirl to generate some classes using swagger files.
I'm trying to split a big file into small pieces and making it more maintainable. But when the file is rendered the tag with the content from the other file is…
![](../../users/profiles/7240850.webp)
Guillermo Pastor Díez
- 67
- 1
- 6
2
votes
2 answers
Calling a function as a parameter in a template call in Play
In Play/Scala; I am confused as to why this won't compile:
@(tabNames: Seq[String])
@isActive(idx: Int) = {
@if(idx < 1) {
"active"
} else {
""
}
}
![](../../users/profiles/2960275.webp)
jesus g_force Harris
- 468
- 5
- 15
2
votes
0 answers
Play framework Scala Controller method called twice
I'm facing an issue while calling a Play Scala controller method with a large amount of data. I have file upload method which takes 2 uploaded files and processes them. If the file size is big, the controller method is getting called twice. If the…
![](../../users/profiles/6062443.webp)
Rajashree Gr
- 417
- 5
- 14
2
votes
1 answer
(Play Framework) Suitable IDE to edit Twirl templates?
I'm editing some fairly long Twirl template html files in Intellij IDEA, but it's basically like a text editor without function/variable prompt or even the correct keyword highlighting.
Curious to know if there's a plugin/editor that will make my…
![](../../users/profiles/5818399.webp)
Andy
- 115
- 1
- 5
2
votes
1 answer
PlayFramework 2.5 Templates - Twirl Dependency Injection
since PlayFramework is moving like year from global state using dependency injection and none is probably able there to rewrite guides/tutorials I can not find answer to my question anywhere.
Since Play 2.5 you have to stay away from global state…
![](../../users/profiles/7423213.webp)
Martin Dluhy
- 133
- 8
2
votes
0 answers
scala twirl autocomplete in intelliJ outside play
I'm using scala twirl templating outside the play framework (using akka-http instead) for generating email bodies, but it seems like intelliJ has no idea how to parse the twirl files (they are basically plain text files).
I would love to see some…
![](../../users/profiles/1726544.webp)
Ákos Vandra
- 1,327
- 12
- 29
2
votes
0 answers
Overloading template functions
I want to have a template function like:
@myInput("myLabel")
but that it can optionally take additional parameters like:
@myInput("myLabel", Validation.Max(5), Validation.Min(3).....)
and some sort of logic inside the template function, that…
![](../../users/profiles/1043677.webp)
lqbweb
- 1,397
- 1
- 16
- 30
2
votes
1 answer
Generate Scala Source from Twirl Template
I know play-twirl is used to generate Scala sources that contain template functions which can be called at runtime.
Is there a way to generate arbitrary Scala source files with play-twirl?
For example
I'd like to automate the creation of some…
![](../../users/profiles/574815.webp)
Dylan
- 11,912
- 2
- 35
- 64