Questions tagged [twirl]

The Play framework Scala template engine repackaged for stand-alone use.

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…
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…
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…
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,…
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…
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…
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…
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…
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 { "" } }
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…
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…
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…
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…
Á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…
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…
Dylan
  • 11,912
  • 2
  • 35
  • 64
1
2
3
9 10