Skip to main content
Version: 1.0.0

Blocks

Blocks are low-level reusable fragments under yui/blocks/*. They are meant for small, repeated rendering units that should stay consistent across pages/components.

What Belongs to Blocks

Good block candidates:

  • head partials (meta, fonts, styles, scripts)
  • totals row renderers
  • popup shells
  • shared fragments that appear in several components

Poor block candidates:

  • full feature modules (use components)
  • route orchestration (use pages)
  • global skeleton contract (use layouts)

Main Block Groups in Plugin

  • _head/*: default head partials used by base layout
  • cart/*: cart totals and cart-specific fragments
  • checkout/*: checkout totals, action rows, checkout fragments
  • global/*: popup templates and shared global fragments
  • customer/*: account sidebar and account fragments
  • errors/*: error page fragments

Real Examples

  • yui/blocks/_head/meta.twig
  • yui/blocks/cart/totals/grand_total.twig
  • yui/blocks/checkout/totals/switch.twig
  • yui/blocks/global/popup/minicart-sidebar.twig
  • yui/blocks/form-resources.twig

Example Usage

{% include 'yui/blocks/_head/meta.twig' %}
{% include 'yui/blocks/checkout/totals/switch.twig' %}

Developer Guidelines

  1. Keep blocks focused and small.
  2. Prefer parameterized rendering over hidden global dependencies.
  3. Do not couple blocks to a single page route.
  4. Keep translation keys and labels consistent with existing cart/checkout semantics.
  5. If a block starts to own business behavior, promote it to a component.