I read the documentation http://www.playframework.org/documentation/1.1/tags#ageta and I don’t get it.
Can someone provide a better, easier to understand example ?
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.
This is essentially a way to avoid copying and pasting a bunch of HTML repeatedly and then changing a dozen little details in it.
The starting example they give in the documentation (which I know you’ve read, but which I’l quote here for ease of reference) is this:
If you imagine starting with that markup on your page and then adding a second field to the form, you’d have to copy/paste that entire block and then change
&{'user.name'},user_name,user.name,${user?.name},user.name, anduser.name(each a separate reference to the same basic field) just to get the new markup to apply to your new field.And that’s just more typing than some of us are willing to undertake merely to add a field to a darn form.
The replacement
#{field 'foo'}allows is this:The advantage here is that
user.nameappears in exactly one place. If you were to copy/paste this markup to add another field, you’d have to make only one replacement: the one in the#{field ...}tag.The end result is that it’s easier to develop standard markup for the many fields on your form without having to do a lot of error-prone manual replacement of the labels, names, IDs, current values, error messages, classes, et cetera.