Home β€Ί Core Learning Journey β€Ί Session 4 β€” Components, dialogs & HTL

Session 4 β€” Components, dialogs & HTL

Purpose: Learn the anatomy of an AEM component: HTL render script, dialog, and how authors configure instances.

Who this page is for

AudienceWhy it matters to you
Frontend engineersYour primary deliverable in AEM
Backend engineersYou will pair models with these

Component anatomy

An AEM component is a folder in /apps. For the PHI plan-card:

/apps/phi-academy/components/plancard/
  β”œβ”€β”€ plancard.html          ← HTL render script (the "JSX")
  β”œβ”€β”€ _cq_dialog/.content.xml← author dialog (the "props form")
  β”œβ”€β”€ .content.xml           ← component metadata (title, group, superType)
  └── clientlibs/            ← optional component-scoped CSS/JS
PieceReact equivalent
HTL scriptThe component's JSX
DialogStorybook controls / props form β€” but for authors, persisted to JCR
sling:resourceSuperTypeextends a base component
Component groupPalette category authors pick from

HTL in five expressions

HTL (HTML Template Language) is intentionally logic-poor β€” think server-side JSX with escaping on by default:

<div class="plan-card" data-sly-use.model="com.academy.phi.models.PlanCardModel">
  <h2>${model.title}</h2>                        <!-- auto XSS-escaped -->
  <p data-sly-test="${model.subtitle}">${model.subtitle}</p>   <!-- conditional -->
  <ul data-sly-list.benefit="${model.benefits}"> <!-- iteration -->
    <li class="${benefit.covered ? 'tick' : 'cross'}">${benefit.label}</li>
  </ul>
  <a href="${model.ctaLink @ extension='html'}">${model.ctaText}</a>  <!-- context-aware output -->
</div>
HTLJSX equivalent
data-sly-use.model="…"const model = usePlanCard()
${model.title}{model.title} (escaped, like JSX)
data-sly-test{condition && …}
data-sly-list{items.map(…)}
data-sly-resourceRendering a child component
@ context='…'Choosing the escaping strategy (no JSX equivalent β€” HTL is stricter)

No arbitrary logic is allowed in HTL β€” anything conditional beyond simple tests belongs in the Sling Model (Session 5). That is the platform enforcing the "dumb view, smart hook" split you already practice.

Dialogs

Dialogs are XML definitions of Granite/Coral form fields. The values authors enter are written as properties on the component's content node β€” which your model then reads. Field types cover text, rich text, path pickers, asset pickers, checkboxes, multifields (repeating rows β€” used for the benefits table).

Authoring safety rules

Quick navigation