Previous Next JavaScript must be enabled to correctly display this content

## 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.

- Template Substitution Syntax
  Use substitution strings within templates to reference component values.
- Escape Filters
  Learn how to escape special characters in the substitution value.
- Built-in Substitution Strings
  Learn about built-in substitution strings.
- Substitutions in Text Messages (Legacy)
  Learn about using substitutions in text messages.
- Templates in JavaScript
  Learn about using templates from JavaScript.

Parent topic: How Oracle APEX Uses Templates

### 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".`

See Also:

Using Substitution Strings

Parent topic: Basic Templates

### 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.`

See Also:

Controlling Output Escaping in Substitution Strings

Parent topic: Basic Templates

### 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.

Parent topic: Basic Templates

### 3.5.1.4 Substitutions in Text Messages (Legacy)

Learn about using substitutions in text messages.

Note:

Application-defined or system-defined text messages described in this topic have been designated as legacy functionality. If your application's Compatibility Mode is 24.2 or later, Oracle recommends wrapping the message name in curly braces ({}) as described in Substitutions in Text Messages (24.2 or later).

Although Oracle still supports legacy application components, Oracle does not recommend using them.

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.`

See Also:

APP_TEXT$Message_Name, APP_TEXT$Message_Name$Lang

Parent topic: Basic Templates

### 3.5.1.5 Templates in JavaScript

Learn about using templates from JavaScript.

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.

Parent topic: Basic Templates