I have a field.scala.html that should take a control as input and render it.
Right now I do like this:
@field("shop", "name", true) { (modelName, fieldName, required) =>
@textInput(modelName, fieldName, required)
}
But I would like to do it like this: @field("shop", "name", true)(textInput)
I see 2 ways it could be done but not sure if it's possible:
Maybe there is a better way?
Templates are just functions. If field.scala.html takes a:
(String, String, Boolean) => Html
And textInput.Scala.html has the following parameter declaration:
@(modelName: String, fieldName: String, required: Boolean)
Then what you want to do will just work. If not try passing textInput.apply.