OroBAP's Twig Placeholder Tag

Poking around one of the base OroCRM templates, I came across an odd looking tag I'd never seen before.

#File: vendor/oro/platform/src/Oro/Bundle/UIBundle/Resources/views/Default/index.html.twig
...
{% placeholder scripts_after %}
...

Some quick Googling left me stumped — I couldn't find any reference to a placeholder twig tag. That's because it's a custom OroBAP tag, provided via a Twig extension.

Explaining how twig extensions work is more work than a quickies post entails. Fortunately, the README.md for the OroBAP UIBundle provided plenty of documentation on this custom tag.

#File: vendor/oro/platform/src/Oro/Bundle/UIBundle/README.md
## Introduction to placeholders

In order to improve layouts and make them more flexible a
new twig token `placeholder` is implemented. It allows us to
combine several blocks (templates or actions) and output
them in different places in twig templates. This way we can
customize layouts without modifying twig templates.    
...

The placeholder tag is way to add additional twig templates to certain areas without needing to modify the base application template files. For example, the OroBAP core team used the scripts_after placeholder in the the OroLocaleBundle bundle.

#File: vendor/oro/platform/src/Oro/Bundle/LocaleBundle/Resources/config/placeholders.yml
placeholders:
    scripts_after:
        items:
            locale_settings:
                order: 500

The inserts a locale_settings item into the HTML output wherever the {% placeholder scripts_after %} tag is used. The order field controls which order the placeholders are rendered in, since any bundle developer can add a placeholder via a placeholders.yml file.

What's a locale_settings item? That's defined later in the file.

#File: vendor/oro/platform/src/Oro/Bundle/NavigationBundle/Resources/config/placeholders.yml
items:
    locale_settings:
        template: OroLocaleBundle::locale_settings.html.twig

So, as you can see, the placeholder tag allowed the OroLocaleBundle author to insert the OroLocaleBundle::locale_settings.html.twig twig template into the document head without modifying the root document.