Skip to content

v1.2.0

Choose a tag to compare

@github-actions github-actions released this 09 Jul 07:11

What's Changed

Added

  • styleguide.data.yaml / styleguide.data-<name>.yaml sidecars + styleguide_data() Twig function. A component/page/doc directory may now ship one or more pure-YAML sidecars — styleguide.data.yaml (the DEFAULT set, no-arg styleguide_data()) and any number of styleguide.data-<name>.yaml NAMED sets (styleguide_data('<name>')), <name> matching the SAME [a-z0-9-]+ id rule already used for styleguide.<variant>.twig variant ids — a flat naming family living directly in the component directory, mirroring the variant-sibling convention rather than introducing a second nested data/ concept. 'default' is a RESERVED set name — styleguide_data('default') throws an \InvalidArgumentException before touching the filesystem, pointing at the no-arg call instead, so a stray styleguide.data-default.yaml can never be loaded through either door. Solves a real gap: Twig's {% include %} can't export variables back to the caller, so several styleguide.<variant>.twig siblings sharing bulky demo data had no clean way to share it short of duplicating the data or an {% extends %}-based "data template" trick (still valid as an escape hatch for expression-heavy demos that can't be plain YAML). Resolution is always scoped to the CURRENTLY rendering component's own directory — there is no cross-component lookup — and its "currently rendering" context is cleared (reset to null) immediately after each render completes, so a styleguide_data() call reaching the environment between renders throws instead of silently reusing a stale directory. Any { placeholder: {...} } node anywhere in the tree — at any depth — is recursively resolved into the exact shape placeholder() itself returns, with ratio: (colon-separated, e.g. "16:9") accepted as a YAML-only alias for Placeholder::generate()'s own aspect: option (slash-separated; the alias converts the separator too, and an explicit aspect: always wins over ratio: when both are present); src:/url: string values are recursively rebased onto templateUrl/homeUrl (same rules as resolveAssetUrl() — including root-relative paths like /dist/foo.png, which ARE rebased, not treated as absolute). An invalid <name> (doesn't match [a-z0-9-]+, which also rejects traversal-shaped values like '../x', 'a/b', '%2e%2e') is rejected before the filesystem is touched; a missing set → RuntimeException naming the expected path (relative to templates_path — the absolute path is logged via error_log() instead, never leaked into rendered 500-page markup) AND enumerating every data set actually present in that directory (a typo aid); an empty/null/{}/[] sidecar resolves to [], while a bare-scalar top-level node throws a RuntimeException naming the actual shape found; malformed YAML → Symfony's ParseException propagates unchanged (same uncaught contract as styleguide.yaml itself), and since no object/custom-tag parse flags are ever passed, a !php/object-tagged node resolves to null (never a real PHP object) and an arbitrary custom tag hits the same ParseException. Never collides with variant-sibling discovery (.yaml vs. the .twig-only glob). Discovered while wiring mairateam's shared hero demo data. See README.md § YAML sidecar data and docs/API.md § styleguide_data().

Pull Requests

  • #68 — feat: styleguide.data.yaml sidecar + styleguide_data() Twig function

Full Changelog: v1.1.2...v1.2.0