title: Thymeleaf: How to use fragment parameter in expressions
body: <p>Is there a way to use a fragment parameter in an expression?</p>
  
  <p>I'd like to create a fragment to show fields with their corresponding binding errors e.g. like:
  </p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;div th:fragment="alert (field, fieldLabel)"&gt;
      &lt;label&gt;&lt;span th:text="${fieldLabel}"&gt;Label:&lt;/span&gt;&lt;input type="text" th:errorclass="field_error" th:field="*{field}"/&gt;&lt;/label&gt;
      &lt;div th:if="${#fields.hasErrors(field)}"&gt;&lt;span th:errors="*{field}"&gt;Some error&lt;/span&gt;&lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Getting the fragment with:</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;div th:replace=":: alert (field='firstName', fieldLabel='Firstname')"&gt;Field&lt;/div&gt;
  </code></pre>
  
  <p>How do I use the field parameter in the expressions for the th:field and th:errors attributes? *{field} does at least not work.</p>