Skip to content

<xmod:IfEmpty>

<xmod:IfEmpty> renders the content between its opening and closing tags only when Value is empty — an empty string "" or null. Use it to show a placeholder when a field has no data.

For if/else patterns, place an <xmod:IfEmpty> and an <xmod:IfNotEmpty> back to back with the same Value.

Example

Show a placeholder image when the record's imageUrl is blank, and the actual image when it isn't:

html
<xmod:Template Id="Employees">
  <DetailTemplate>
    <h3>[[FirstName]] [[LastName]]</h3>
    <xmod:IfEmpty Value="[[imageUrl]]">
      <img src="/images/NoImage.png" alt="No photo on file" />
    </xmod:IfEmpty>
    <xmod:IfNotEmpty Value="[[imageUrl]]">
      <img src="[[imageUrl]]" alt="[[FirstName]] [[LastName]]" />
    </xmod:IfNotEmpty>
    <h4>Biography</h4>
    <div>[[Bio]]</div>
  </DetailTemplate>
</xmod:Template>

Properties

PropertyValuesDefaultDescription
Valuestring | tokenThe value tested for emptiness

Property Details

  • Value: The value to test. Most commonly a [[FieldName]] token bound to a database column. The content renders only when the resolved value is an empty string or null. Whitespace-only values (e.g. " ") count as non-empty.

    When the attribute uses a field token, single-quote the value: Value='[[FieldName]]'[[FieldName]] contains brackets that conflict with double quotes inside the XML attribute parser.