iscontent Element
Modify the HTTP header (set the content type) of the generated output stream sent to the browser or email client. The HTTP header is identified by its MIME type.
- type = MIME_type
Allowed data type: string or expression.
<doc-content-callout header="Note" variant="note"> <div><p>It's possible, though rarely helpful, to generate one type of content through the type command and then encode the output with a different content type. Generally, the on and off commands suffice.</p></div> </doc-content-callout>MIME_type
specifies the MIME type of the generated output stream. If no type is specified, theMIME_type
is set totext/html
. Generally, storefront pages and email output are set totext/html
.Use an expression for dynamic content types. You can set the encoding explicitly using thecharset
attribute, or determine it implicitly from the content type.- charset = char_set
Allowed data type: string Expressions are not allowed.
char_set
defines the character set of the output stream. The default value is the default encoding of the operating system that runs the Salesforce B2C Commerce application server. The default encoding is UTF8 and shouldn't be changed, unless really necessary.- encoding = "on" | "off" | "html" | "xml" | "wml"
Naming a content type, for example
html
, has the same affect as using theon
value and also selects the type of output. All data processed after the first occurrence of the<iscontent/>
tag is affected by this setting. Encoding converts characters that could cause a syntax conflict. For example, the ampersand symbol is converted to & in HTML encoding. The default encoding value ishtml
. For more information, see Encoding Expression Results in isprint.on
turns on encoding for the output stream. This is used in combination with the charset to determine the characters in the output stream.off
turns off encoding for the output stream.html
turns on encoding and specifies html as the type of encoding. This is used in combination with the charset to determine the characters in the output stream.xml
turns on encoding and specifies xml as the type of encoding. This is used in combination with the charset to determine the characters in the output stream.wml
turns on encoding and specifies xml as the type of encoding. This is used in combination with the charset to determine the characters in the output stream.
- compact = "true" | "false"
Allowed data type: boolean. Expressions are not allowed.
HTML code often contains white space that doesn't have any affect on the visual appearance of a page and is primarily used to make the code of a template easier to read. When compact is set to true, unnecessary white space is removed from the output stream. Compact is on by default. See the general examples for an example of how the compact attribute works.
In most cases, you don't need to set the type because this is done automatically by the node or pipelet that calls the template. These nodes set the MIME header as follows:
Node/Pipelet | MIME Type Setting |
---|---|
Interaction-continue or interaction-end node | text/html |
SendMail pipelet | text/plain |
dw.net.Mail (as part of a script run by a script node) | text/plain |
If you want to overwrite these defaults, or if you want your template to generate a different type of output, you can explicitly specify another MIME type in the type attribute. See alsoSending Email via Scripts or Hooks
Additionally, the <iscontent/>
tag:
-
Sets the character encoding of the generated output stream
-
Allows HTML, XML or WML encoding for the whole template
-
Removes unnecessary spaces by means of the compact attribute
You can also dynamically select
<iscontent/>
settings. For example, you can use a dynamic expression to set the MIME type.
This example sets the content type and character set of the output stream:
The following is a typical formatting of HTML code, with tabs or whitespace to make it more readable:
Such white spaces increase the size of a file, which potentially increases the time necessary to transmit a page to the client. To optimize the output code of a template don't set compact to false
. Because compact is set to true
by default, you can use:
<iscontent compact="true">
or <iscontent/>
This tag ensures that all extra white space is removed during the template conversion process, for example, converting the previous code into:
The template compacting feature compresses templates before transmitting them to a client's browser. The process eliminates all unnecessary white spaces and can reduce the load time at client browsers.
Compacting can't be toggled within the template. The feature isn't applied to templates included within a calling template using the <isinclude/>
tag. The statement must be used in each template that is to be compacted.
HTML statements that use formatted content, such as the <pre>
tag, might not appear properly if used in a template with compacting. If a template uses these tags, avoid using the compacting feature or use dynamic content, created with expressions, for the formatted material. For example, to keep the additional spaces in the statement:
You can use:
To ensure that the <pre>
tag works in a compacted template:
Use an <isprint/>
statement:
The following examples shows the resulting Content-Type: HTTP header for different values of the type
and charset
attributes:
<iscontent> Usage | Resulting Content-Type | Comment |
---|---|---|
<iscontent type ="text/html" charset="ISO-8859-1" /> | text/html;charset=ISO-8859-1 | |
<iscontent type="text/html" /> | text/html;charset=UTF-8 | The charset used is the default encoding for ISML "UTF-8". |
<iscontent type="plain" /> | plain;charset=UTF-8 | The charset used is also the default encoding for ISML, "UTF-8". |
<isscript>pdict.ContentType = 'text/html';</isscript> <iscontent type="${pdict.ContentType}" charset="ISO-8859-1" /> | text/html;charset=ISO-8859-1 | |
<isscript>pdict.ContentType = 'text/html';</isscript> <iscontent type="${pdict.ContentType}" /> | text/html;charset=UTF-8 | The charset used is the default encoding for ISML, "UTF-8". |
<iscontent charset="UTF-8" /> | text/html;charset=UTF-8 | The type used is the default MIME type for ISML, "text/html". |
<iscontent compact="true" /> | text/html;charset=UTF-8 | The type used is the default MIME type for ISML, "text/html". The charset used is the default encoding for ISML pages, "UTF-8". |
If text of the page appears in the ISML template before the <iscontent/>
tag, either directly or through a script containing out.print()
statements, the type
and charset
specified in the tag can't be guaranteed to take effect. For best results, the <iscontent/>
tag should always be first in an ISML template.