Questions tagged [twirl]

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

146 questions
2
votes
2 answers

illegal start of simple expression

I am trying to execute a simple java program using play. I am getting a compilation error as illegal start of simple expression. I have searched answers for this question, but I didn't get it. My code looks like this: @(products…
2
votes
1 answer

Code assistance in IntelliJ IDEA for implicit variables in Twirl Template

I am building a web app in Java using the Play! framework and Twirl template engine, using IntelliJ IDEA. In the template there are a number of implicit variables which are available(flash, session, requestHeader). I can successfully reference any…
2
votes
1 answer

Rendering newline charactors from variable in Twirl

I have a toy Play framework project. And my Java code is something like: String r = "apple\nbanana"; return ok(index.render(r)); And my index.scala.html is something like @(r: String) …
user3462510
  • 106
  • 6
2
votes
1 answer

How create new Form object in template?

is possible to create new Form object via template? I need this because I don't want reapeat myself and use partial with fields from form. It looks like this: @import play.i18n.Messages @import play.i18n.Lang @()
Adam
  • 126
  • 7
2
votes
0 answers

Play framework forms repeated values - dynamically add controls for new values

I'd like to create a Play form that allows users to enter multiple values for a list in my model. Initially the form should show a single text box, but clicking a "+" button should create a new text box to allow them to enter another value. The…
jrwilliams
  • 63
  • 6
2
votes
1 answer

Check Html fragment nullity with Play Framework 2.3.0

I have a tag in my application with the following structure : @( columns: Integer )(header: Html)(body: Html)
@if(header != null) { @header } …
c4k
  • 3,714
  • 3
  • 34
  • 55
1
vote
0 answers

parsing a variable from a scala twirl template to javascrpt in a seperate file

Hi i am currently trying to tidy some code up by moving some javascript into a seperate file however i am having a problem with parsing a variable into that the script needs this is the code i have tried so far: The Script:
shiny est
  • 13
  • 3
1
vote
0 answers

ScalaJS: Referring to non-existent class play.twirl.api.Html

Tried to upgraded from ScalaJS 0.6.x to 1.3.1. Now I'm stuck with this linking error. It's a play framework cross project where I use twirl templates on client and server side. Here are the configuration files. I could also reproduce that error with…
RobertJo
  • 63
  • 8
1
vote
1 answer

Upgrade project to Scala 2.13: JavaConversions is not a member of package collectio

I want to upgrade Scala version in multimodule maven project from 2.11 to 2.13. I changed all Scala version and Scala suffix version in pom.xml, updated the dependency version. I got next error in compilation: …
Vadim
  • 551
  • 2
  • 9
1
vote
0 answers

How to pass implicit value from one template layout to another in Play Framework's Twirl?

let's say I have this controller's Action: def getPost = Action { implicit request => Ok(views.html.post("bla bla bla")) } Now I have two layouts: // baseLayout.scala.html: @(title: String)(content: Html)(implicit req: RequestHeader) ... …
acmoune
  • 1,655
  • 2
  • 13
  • 29
1
vote
1 answer

call twirl template from ScalaJs

The play framework documentation says (https://www.playframework.com/documentation/2.6.x/ScalaTemplates): You can then call this from any Scala code as you would normally call a method on a class: val content = views.html.Application.index(c,…
RobertJo
  • 63
  • 8
1
vote
2 answers

Generic implementation von java.util.Comparator in Scala

I am using twirl templates with Java and Scala. So I am trying to sort a List in the template, but I do not know how to override the Comparator method. My List contains objects of a class designed like: class Foo extends BaseFoo The class…
Spektakulatius
  • 2,195
  • 1
  • 21
  • 37
1
vote
1 answer

Play Framework: Dependency Injection in Sub-Templates

I want to use Scala Templates Dependency Injection. Using it on the entry page it works: @this(assets: AssetsFinder) @(projConfig: ProjectConfig) @main(projConfig) (assets){

Sidebar

} {

Home page

} But if I want to this in a…
pme
  • 11,442
  • 2
  • 35
  • 62
1
vote
0 answers

scala.tools.nsc.Global fails to compile after first compilation error

I've implemented dynamic compilation of Twirl templates and stumbled upon odd problem - instance of scala.tools.nsc.Global works until it fails once with bad source file. Any further attempts to compile valid file fail, it does not produce .class…
expert
  • 26,897
  • 27
  • 105
  • 198
1
vote
1 answer

Play Framework - how to get a value from a function in a Scala template?

So I have this code (all of this is in the one scala.html file): @getLevelAsRoman(level: Integer) : String = @{ @if(level == 1){ @return "I" } @if(level == 2){ @return "II" } @if(level == 3){ @return "III" } } And I call it…
bharal
  • 14,067
  • 31
  • 108
  • 182
1 2
3
9 10