The Power of APEX Template Directives

Search for a command to run...

Oracle APEX already includes Font APEX as the default icon library for Universal Theme. In most cases, that is enough. But in one of my APEX apps, I needed a few icons that were not available there, s

Looking to give your Oracle APEX mobile app a modern, native feel? Here’s a quick hack: add a floating action button that stays anchored at the bottom corner just like in popular mobile apps. This sma

APEX 26.1 has been updated to the Universal Theme. While much of the attention in this release is on AI features, I think the UT improvements are just as important for developers like me who care abou

The apex_barcode package offers a PL/SQL API to generate various types of barcodes. You can output barcodes as SVG (Scalable Vector Graphics) values or as PNG file blobs, making it easy to embed them

Oracle APEX makes it easy to get data on screen fast, but often, the default tabular output isn’t enough. What if you want to highlight statuses, add icons, or display badges all without writing compl

Oracle APEX Template Directives allow us to move data formatting from SQL to HTML, creating easier-to-read queries, improving performance, and reducing the risk of Cross-Site Scripting attacks.
Template Components can be used on any component with the HTML Expression, and we have the following options:

IF: For the IF example we are going to use the DISABLE_FLAG column. If there the column is not null will return Yes else NO.

Token Modifiers
| Condition | Directive |
| --- | --- |
| if_exists_and_true | {if ITEM/} |
| if_exists | {if ?ITEM/} |
| if_not_exists_or_false | {if !ITEM/} |
| if_not_exists | {if !?ITEM/} |
| if_not_false | {if =ITEM/} |
| if_exists_and_false | {if !=ITEM/} |
CASE: For the CASE we are going to use the GENDER column. When M we will show the fa-male icon and fa-female when the value is F.

LOOP: For the LOOP, the column BADGES contains colon-separated values representing all the badges the user has. We are going to break that into <li> elements and add the fa-trophy icon.

The code above will return the following:

WITH and APPLY allow us to add predefined template component plugins and use them inside a template component (nested template component) or in HTML Expressions. In the example below, we will use the BADGE template component plugin to show the value of the FULL_NAME column.

The code above will return the following:

To help us build the WITH/APPLY and add all the custom attributes for each plugin, Matt Mulvaney created the Template Component With/Apply Generator This tool is very helpful for generating the WITH/APPLY for each plugin

##