Add Default Content to a Fragment Slot
Sometimes you might want to provide some default content for a fragment slot if the fragment user doesn't provide their own content. To do this, you add the required elements within a <template>
in your fragment slot's HTML.
For example, you might decide to default to a standard greeting of Hello! in the
greetingArea
slot in case the fragment user does not specify something themselves. To do this:
- In the Fragment Designer, select the fragment slot in the Structure view, then click Code to view the fragment's HTML source.
- Add your default content wrapped in a
<template>
element to the fragment slot's definition within<oj-vb-fragment-slot>
. For example:<oj-vb-fragment-slot bridge="[[vbBridge]]" class="oj-flex-item oj-sm-12 oj-md-12" name="greetingArea"> <template> <h3>Hello!</h3> </template> </oj-vb-fragment-slot>
Now when this fragment is used on a page, here's what it looks like:
Description of the illustration fragmentslot-defaultcontent.png