11.1.5 Understanding Template Options

Template options provide developers with a declarative approach to applying different styles to components on an Oracle Application Express page. About Template Options

Use template options to declaratively apply CSS modifiers to the templates they have chosen for pages, regions, reports, lists, breadcrumbs, items and buttons.

A CSS modifier is a reference to a CSS class defined in a CSS style sheet. CSS modifiers enable a developer to use the same HTML markup but present it in a variety of different styles simply by applying a CSS. Template options reduce the need to have a large number of nearly identical templates defined in a theme in order to achieve different styles for button colors, region widths, font settings, item label markup, and so on.

Examples of how developers can use template options include:

  • Applying different colors or accents

  • Applying different spacing and padding

  • Rendering buttons in different styles, with and without icons

  • Displaying form fields with different alignments.

Without template options, applying these variations would require a large number of nearly identical templates, or in-depth knowledge of CSS. Components that support template options include: pages; regions; classic reports; breadcrumbs; lists; items and labels; and buttons. About Default Template Options

Developers can select default template options that are not part of a template option group.

App Builder automatically applies default template options by rendering the component that references the template. Default template options are not written to an actual component. Instead, a #DEFAULT# substitution string is defined for the component, thus enabling developers to centrally modify the template option defaults.

Developers can choose not to use the template option defaults, which removes the #DEFAULT# substitution string from the component. If template option defaults are disabled, then developers can selectively apply available template options to a component. All template options that are selected directly when editing the component are written to the component's metadata, represented by their corresponding CSS classes string. At runtime, the selected template options and default template option are part of the default are combined with the component's CSS classes string and applied to the component. About Template Option Groups and Presets

Developers can define the purpose of related template options by creating template option groups.

Examples of template option groups include Button Size, Button Style, List Examples, List Style, and Form Label Position. When developers create a template option group, they can specify a template option preset at the template-level. For example, suppose you have a button template that has the template options Large and Small. If you define Small as the preset, then any new button referencing the template would automatically have the template option Small applied to it when is it created. Template options that are part of a group are optional unless a present is defined at the template-level.