Is it possible to have auxiliary constructors in Play 2.0 templates?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
By “constructor” I assume you mean argument list with different arguments. I don’t know of a built-in way to do this, but I’ve only just starting learning Play.
However you can use the Enhance My Instance™ pattern to achieve the same effect:
Using the to-do list example, say your
index.scala.htmltemplate begins:In
Application.scalayou call this withIf you want to leave out the task list:
Now you can call it thus:
This is essentially just the pimp-my-library pattern using
.typeto narrow the scope to a particular instance, in this case theviews.html.indexobject.