<xmod:Format>

The Format tag allows you to present your data in a more user-friendly format. With it, you can format currency, numbers, dates. You can perform text substitutions and regular expression substitutions. It also provides you with the ability to cloak text - i.e. obfuscate it so that web 'bots have more difficulty scraping your web pages for data like email addresses.

Syntax

<xmod:Format
    Type="Numeric|Float|Date|Text|RegEx|Cloak|HtmlEncode|HtmlDecode|UrlEncode|UrlDecode"
    Value="string"
    Pattern="string"
    Replacement="string"
    MaxLength="integer"
    InputCulture="locale ID"
    OutputCulture="locale ID"

/>

Remarks

The Format tag is used to operate on data - usually from form fields, but it can also operate on hard-coded values. It gives you the ability to take a value and adjust its appearance. For instance the value "1" could be formatted as "01", "1", or "1.00". The value "2005-05-21" could be formatted like "05/21/2005", "Sat May 21 2005", etc.

The Format tag will format values as numbers (no floating point), floating-point numbers, and dates. It will also allow you to perform text substitutions as well as regular expression substitutions. Format tags are empty tags, meaning that they do not contain any inner text. Please follow the XHTML syntax for empty tags which is to write them as a single tag. (i.e. <xmod:format ... /> See example)

 

Back to top

Example

<xmod:template ...>
    ...
    <itemtemplate>

      EXAMPLE #1
      If Quantity=5 Output Value Will Be: 05.00
      <xmod:Format Type="Float" Value='[[Price]]' Pattern="0#.00"/>

      EXAMPLE #2
      If Quantity=5 Output Value Will Be: 05
      <xmod:Format Type="numeric" Value='[[Quantity]]' Pattern="d2"/>
      NOTES: The "d" pattern is a pre-defined pattern for working
      with numeric values. It works only with whole numbers. It
      instructs the tag to display the value as a decimal (base 10).
      The "2" instructs the tag to display the number as a 2 digit
      number.

      EXAMPLE #3
      If Quantity=5
        Output On US Systems:$5.00
        Output On United Kingdom Systems:£5.00
      <xmod:Format Type="Float" Value='[[Price]]' Pattern="c"/>
      NOTES: No output culture is specified so the output defaults
      to the web server's culture. The "c" pattern stands for
      formatting the value as currency.

      EXAMPLE #4
      If Quantity=5
        Output On US Systems:£5.00
        Output On United Kingdom Systems:£5.00
      <xmod:Format Type="Numeric" Value='[[Price]]' Pattern="c"
        outputculture="en-GB"/>
      NOTES: United Kingdom English is specified as the output
      culture, effectively forcing the value to be formatted
      with the £ symbol, even on US systems.
      EXAMPLE #5
      If theDateColumn=04/25/2013
        Output Value Will Be:04/25/2013
      <xmod:Format Type="Date" Value='[[theDateColumn]]' Pattern="MM/dd/yyyy"/>


    </itemtemplate>

    ...
</xmod:template>
Back to top