v1.2.0
What's Changed
Added
styleguide.data.yaml/styleguide.data-<name>.yamlsidecars +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-argstyleguide_data()) and any number ofstyleguide.data-<name>.yamlNAMED sets (styleguide_data('<name>')),<name>matching the SAME[a-z0-9-]+id rule already used forstyleguide.<variant>.twigvariant ids — a flat naming family living directly in the component directory, mirroring the variant-sibling convention rather than introducing a second nesteddata/concept.'default'is a RESERVED set name —styleguide_data('default')throws an\InvalidArgumentExceptionbefore touching the filesystem, pointing at the no-arg call instead, so a straystyleguide.data-default.yamlcan never be loaded through either door. Solves a real gap: Twig's{% include %}can't export variables back to the caller, so severalstyleguide.<variant>.twigsiblings 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 tonull) immediately after each render completes, so astyleguide_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 shapeplaceholder()itself returns, withratio:(colon-separated, e.g."16:9") accepted as a YAML-only alias forPlaceholder::generate()'s ownaspect:option (slash-separated; the alias converts the separator too, and an explicitaspect:always wins overratio:when both are present);src:/url:string values are recursively rebased ontotemplateUrl/homeUrl(same rules asresolveAssetUrl()— 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 →RuntimeExceptionnaming the expected path (relative totemplates_path— the absolute path is logged viaerror_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 aRuntimeExceptionnaming the actual shape found; malformed YAML → Symfony'sParseExceptionpropagates unchanged (same uncaught contract asstyleguide.yamlitself), and since no object/custom-tag parse flags are ever passed, a!php/object-tagged node resolves tonull(never a real PHP object) and an arbitrary custom tag hits the sameParseException. Never collides with variant-sibling discovery (.yamlvs. the.twig-only glob). Discovered while wiringmairateam's shared hero demo data. SeeREADME.md§ YAML sidecar data anddocs/API.md§styleguide_data().
Pull Requests
- #68 — feat: styleguide.data.yaml sidecar + styleguide_data() Twig function
Full Changelog: v1.1.2...v1.2.0