3.5.1 Basic Templates

Templates in Oracle APEX support the use of substitution strings to pass information and replace any character string with another value.

3.5.1.1 Template Substitution Syntax

Use substitution strings within templates to reference component values.

Pass information and replace any character string with another value using template substitution syntax. To view the most current list supported of substitution strings for a given template, view the template definition and find the Substitution Strings report. See Viewing Templates on the Templates Page.

The following table summarizes two approaches to template substitution syntax.

Type Description Example Result
Placeholder Substitution

Use Placeholder substitution string syntax within a template to reference component values.

Placeholder substitution strings available within a template are denoted by the number symbol (#).

Hello #NAME#

Hello APEX Community

Session State Substitution

Reference page or application items using Session State Substitution string syntax (also called &ITEM. syntax):

  • Reference the page or application item in all capital letters
  • Precede the item name with an ampersand (&)
  • Append a period (.) at the end

Hello &NAME.

Hello APEX Community

Tip:

Use double quotation marks for special characters or case sensitivity. For example:

#"Name"#

&"Name".

3.5.1.2 Escape Filters

Learn how to escape special characters in the substitution value.

Escape special characters in the substitution value by appending an exclamation mark (!) followed by a predefined filter name to a page or application item name, report column, or other substitution string. Output escaping is an important security technique to avoid Cross Site Scripting (XSS) attacks in the browser.

Escape Filter Description Classic Syntax Modern Syntax
ATTR ATTR escapes reserved characters in a HTML attribute context. #NAME!ATTR# &NAME!ATTR.
HTML HTML escapes reserved HTML characters. #NAME!HTML# &NAME!HTML.
JS JS escapes reserved characters in a JavaScript context. #NAME!JS# &NAME!JS.
STRIPHTML STRIPHTML removes HTML tags from the output and escapes reserved HTML characters. #NAME!STRIPHTML# &NAME!STRIPHTML.
RAW RAW preserves the original item value and does not escape characters. #NAME!RAW# &NAME!RAW.

3.5.1.3 Built-in Substitution Strings

Learn about built-in substitution strings.

App Builder supports many built-in substitution strings. You can reference these substitution strings to achieve specific types of functionality. See Using Built-in Substitution Strings to view a complete list of all availble built-in substitution strings.

3.5.1.4 Substitutions in Text Messages

Learn about using substitutions in text messages.

To access application-defined or system-defined text messages, use the built-in substitution APP_TEXT$Message_Name, APP_TEXT$Message_Name$Lang, for example:

&APP_TEXT$MY_MESSAGE!HTML.

&APP_TEXT$MY_MESSAGE$NL!HTML.

3.5.1.5 JavaScript in Templates

Learn about using JavaScript in templates.

You can also use JavaScript API apex.util.applyTemplate to evaluate templates on the client side.

See Also:

applyTemplate in Oracle APEX JavaScript API Reference.