compare

toc
<mm:compare> Compares the value of a context variable to a String value. Only if they are equal the body is evaluated.
see alsoisempty | isnotempty | isgreaterthan | islessthan
attributes
  • referid
    Which context variable to compare. It this attribute is missing, then the value of the parent `writer' is taken.
  • value (Either `value', `valueset', `referid2' or 'regexp' must be present.)
    The value to which you want to compare, this is always a String.
  • valueset (Either `value', `valueset', `referid2' or 'regexp' must be present.) (since: MMBase-1.7)
    List of values. Compare is done with each, and total result is true if one of them evaluates true.
  • referid2 (Either `value', `valueset', `referid2' or 'regexp' must be present.)
    The value can also be another context variable, which is not necessarily a string. The type (set by `vartype') is taken into account.
    see: vartype attribute of writer
  • regexp (Either `value', `valueset', `referid2' or 'regexp' must be present.) (since: MMBase-1.8)
    Matches value to a regular expression. See javadoc of java.util.regex.Pattern
condition attributes
writerreferrer attributes
example 1
    <mm:import id="carry_out">yes</mm:import>
    <mm:compare referid="carry_out" value="yes">
        Body should be carried out!
    </mm:compare>
    <mm:compare referid="carry_out" value="no">
        Body should not be carried out!
    </mm:compare>
    
example 2

      <mm:compare referid="zipcode" regexp="(?i)[0-9]{4}\s?[a-z]{2}">
         zip-code correct.
      </mm:compare>