How to use # {field 'variable'}

I read the documentation http://www.playframework.org/documentation/1.1/tags#ageta and I do not understand.

Can someone provide a better, more understandable example?

+3
source share
1 answer

This is essentially a way to avoid copying and pasting a bunch of HTML multiple times and then changing a dozen small details in it.

The initial example that they cite in the documentation (which, as I know, you read, but which I quote here for the convenience of links):

<p>
  <label>&{'user.name'}</label>
  <input type="text" id="user_name" name="user.name" value="${user?.name}" class="${errors.forKey('user.name') ? 'has_error' : ''}">
  <span class="error">${errors.forKey('user.name')}</span>
</p>

, , / , &{'user.name'}, user_name, user.name, ${user?.name}, user.name user.name ( ), .

, , .

#{field 'foo'} :

#{field 'user.name'}
<p>
  <label>&{field.name}</label>
  <input type="text" id="${field.id}" name="${field.name}" value="${field.value}" class="${field.errorClass}">
  <span class="error">${field.error}</span>
</p>
#{/}

, user.name . / , , : #{field ...}.

, , , , , , , , .. .

+3

Source: https://habr.com/ru/post/1774443/


All Articles