Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java Play2 - Generic templates?

is it possible to create generic templates?

Pseudo code:

@(myForm: Form[T])

So I can reuse them like this:

@inputText(
                myForm("title"), 
                '_label -> "title"

            )
  • If yes, How do I do it?
like image 602
Maik Klein Avatar asked Aug 24 '12 16:08

Maik Klein


1 Answers

Use the magic underscore for that:

@(form: Form[_])

This is called an existential type in Scala, it roughly means "there exists a type parameter but I don't care what it is".

like image 184
Marius Soutier Avatar answered Oct 18 '22 01:10

Marius Soutier