Thomas
Thomas

Reputation: 2767

How can I pass a play template scala variable as input to a scala function?

Im not sure if i got the nomenclature right in the title of my question, Im new to play. Basically I wanted to break my html template by calling 2 sub-templates ( passing to them as argument an sub-object from the main template).

So my main template would be

@* patientInfoFrame Template File *@
@(alarm: Alarm)


@import helper._

@* Caller part *@
@calleInfoTemplate(@alarm.callee)

@* Patient part *@
@patientInfoTemplate(@alarm.patient)

where I receive an Alarm object as variable and would build part of the page by calling a second template calleInfoTemplate with a sub-object from the Alarm object and then a third template patientInfoTemplatewith another sub-object.

If I try to compile that it fails saying that @alarm.callee is an illegal start of simple expression.

How can I pass those sub-objects as input to the other templates?

Upvotes: 0

Views: 248

Answers (1)

estmatic
estmatic

Reputation: 3449

You don't need the @ escape character on your variables in this case because you are already inside a dynamic statement (the template call).

@* Caller part *@
@calleInfoTemplate(alarm.callee)

@* Patient part *@
@patientInfoTemplate(alarm.patient)

Upvotes: 1

Related Questions