Passing parameters not working in Twirl


(Pierce Lamb) #1

This is probably a simple issue but I cannot figure it out. I’ve recently taken an existing site and am trying to make it a “site within a site.” As such, I have a main.scala.html and index.scala.html inside my root views package. There is a sub package in views named ‘Wedding’ which also contains a main.scala.html and index.scala.html. My root main (views.main) has the parameters @(title: String)(wrapperContent: Html) specified. My dependent main (views.Wedding.main) is specified as follows

@(hero: Html)(content: Html)

@views.html.main(title = "") {
@hero
....
@content
}

One of my pages based off the dependent main (views.Wedding.main) is specified as follows:

@()

@views.html.Wedding.main(hero = new Html("""...""")) {....}

When I compile I get this error on the latter page:

parameter 'hero' is already specified at parameter position 1
Note that 'title' is not a parameter name of the invoked method.

Any help is appreciated


(Pierce Lamb) #2

Note that I did try removing the “hero =” part, but it didn’t do anything


(Pierce Lamb) #3

I changed my dependent main.scala.html/index.scala.html to different names and it compiled… Will leave this here for posterity in case anyone comes across the same issue


(Marcos Pereira) #4

Hi @plamb,

Could you please create a small project that reproduces the problem? Having access to a reproducer would help us to better understand and solve the problem if there is any.

Best.