How to create an inline variable in the Play framework 2.x Scala template?
Path from the Play’s guide is not clear to me:
@defining(user.firstName + " " + user.lastName) { fullName =>
<div>Hello @fullName</div>
}
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.
First you don’t create a variable but a value meaning it’s read only.
In your example you have created a value
fullNamewhich is accessible inside the curly brackets.Will print Hello Farmor
To define a value which is accessible globally in your template just embrace everything with your curly brackets.
E.g.
In the example you can use the value
formIdanywere.