<ISPRINT>
outputs the results of ISML expressions and template variables. Even though it is possible to output expression results without <ISPRINT>
, you should always use it, because it contributes to optimizing your template code.
The <ISPRINT>
tag does the following:
<ISPRINT>
, the output is formatted according to its type by an appropriate formatter class. For more information about formatter classes, see Formatting Expression Results. You can use three <ISPRINT> automatically encodes the result of expressions and the contents of ISML variables, except for user-defined variables and string constants. During the encoding any special characters, such as ;, <, >, &, ="=, including any named characters of HTML 4.01 (Unicode 160-255) are converted into their HTML counterparts. For example, the character > would be converted into the string >
.
For more information, see Encoding Expression Results.
Note
The encoding is always done after the formatting.
The following example shows a string containing quotation marks, and the corresponding string that is returned by the <ISPRINT>
tag (it is assumed that the template variable product:name has the value 'Nokia 447X Pro 17" Monitor'):
The ISML code in the template is:
<ISPRINT value="product:name">
The HTML code generated is:
Nokia 447X Pro 17" Monitor
And the browser will render this text as:
Nokia 447X Pro 17" Monitor
Expressions outside <ISPRINT>
tags are not automatically encoded. In this case, special characters must be converted with the stringToHtml() function.
<isprint [ encoding = "( on | off )" ] value = "{ISML expression}" [ style = "{Style Identifier}"] | [ formatter = "{Format String}"] [ symbols = "( {Symbol Declaration} | {ISML expression} )" ] [ padding = "( {Padding Constant} | {ISML expression} )" ] >
The first example demonstrates how to use <ISPRINT>
to output an expression that returns a string. The returned string is formatted as defined by either the default formatter (line one), or by using a style (line two), or by a user-defined formatter string (line three).
<ISPRINT value = "#Basket:Offering:Price#"> <ISPRINT value = "#Basket:Offering:Price#" style = "EURO_LONG"> <ISPRINT value = "#Basket:Offering:Price#" formatter = "* #00.0#">
The usage of the symbols
attribute:
<isprint value="#aNumber#" formatter="#.#" symbols="GroupingSeparator=';DecimalSeparator=,"> <isprint value="#aDate#" formatter="h:mm a" symbols="AmPmStrings={ante meridiem, post meridiem}">
The usage of the padding
attribute:
<ISPRINT value = "#Product:Price#" padding = "-10"> //string output: " 5.00 EUR" <ISPRINT value = "#Product:Price#" padding = "+10"> //string output: "5.00 EUR" <ISPRINT value = "#'foolish'#" padding = "+3"> //string output: "foo"
The usage of the encoding
attribute:
<ISPRINT value = "#'>new<'#" encoding = "on"> //string output: ">new<" <ISPRINT value = "#'>new<'#" encoding = "off"> //string output: ">new<"
value
This attribute is required.
value = ISML Expression
Specifies the expression you want to output with <ISPRINT>
.
encoding
This attribute is optional.
encoding = on | off
| encoding handler
Default value is on
. With this attribute, you can explicitly switch automatic encoding on
and off
. Intershop 7 supports encoding in HTML, XML and WML. Even if encoding is turned off
, the functions stringToHtml(), stringToXml() and stringToWml() can be used to encode individual strings.
For more details on how to use encoding types supported by Intershop or add a custom encoding type see: Cookbook - Encoding.
style
This attribute is optional.
style = style identifier
Use this attribute to specify a style identifier. See Formatting Expression Results, for a list of valid style identifiers. Instead of using the style
attribute, you can alternatively define a formatter string using the formatter
attribute.
formatter
This attribute is optional.
formatter = string
Use this attribute to define a formatter string to control how <ISPRINT>
outputs your expression's result. For information on building your own formatter string, refer to Formatting Expression Results. If formatter
is used, style
must be omitted.
symbols
This attribute is optional.
symbols = symbol declaration
Use this attribute to modify the format used for printing. The value of the symbols attribute can be a symbol declaration or an ISML expression that results in a symbol declaration. This attribute supports all properties of
the types char, String and String of java.text.DecimalFormatSymbols
and java.text.DateFormatSymbols
.
For symbol declarations, the following syntax is allowed:
<SymbolsDecl> ::= <SymbolDecl> ( ';' <SymbolDecl> )* <SymbolDecl> ::= <SymbolName> '=' <ValueDecl> <ValueDecl> ::= <Value> | <ValueList> <ValueList> ::= '{' <Value> ( ',' <Value> )* '}'
Note
The values can contain escaped characters. Use a \ for escaping.
padding
This attribute is optional.
padding = padding constant
This is used only with mail templates, namely templates using plain
rather than HTML
type, to define field width and other spacing issues.
For example, when printing a list of product names using a loop statement, you can define a constant field width for every element of the list. The value for padding can be any positive or negative number. The absolute value of padding constant
defines the field width. A positive value produces left-aligned output, a negative value produces right-aligned output. If the output string is greater than the field size, the output string will be truncated at its right end.