TargetedBlock container
The TargetedBlock
container wraps the conditional content.
Configurations
The TargetedBlock
container provides the following configuration options:
Example
The following example demonstrates how to integrate the TargetedBlock
container:
export default async function decorate(block) { const blockConfig = readBlockConfig(block);
const { fragment, type, segments, groups, cartRules, } = blockConfig;
const content = (blockConfig.fragment !== undefined) ? await loadFragment(fragment) : block.children[block.children.length - 1];
render.render(TargetedBlock, { type, personalizationData: { segments, groups, cartRules, }, slots: { Content: (ctx) => { const container = document.createElement('div'); container.append(content); ctx.replaceWith(container); }, }, })(block);}