Releases: josbeir/sugar
0.6.6
0.6.5
0.6.4
0.6.3
0.6.2
Highlights
-
Added new pass-through directive:
s:trim- Compile-time whitespace trimming for elements where indentation/newline-only text nodes should be removed.
- Ideal for compact inline output such as
<title>...</title>. - Includes validation and deterministic errors for unsupported usage:
- presence-only attribute (no value allowed)
- supported on HTML elements only (not
<s-template>/ component tags).
-
Fixed component boolean attribute rendering (from PR #34)
- Preserves presence-only attributes (e.g.
x-cloak) instead of renderingx-cloak="". - Ensures boolean attributes are correctly propagated and merged for component root elements.
- Preserves presence-only attributes (e.g.
Commits included
f8d40d7— fix: preserve boolean attributes (e.g.x-cloak) on component root elements (#34)736a887— feat: adds:trimwhitespace pass with docs and tests546c57a— fix: validate and constrains:trimusage
0.6.1
What's Changed
This release adds the ability to use s:block, s:append and s:prepend directives on s:includes effectively assigning partial content to blocks.
Simple example combining s:include with s:append and a control flow expression s:if:
<s-template s:include="partials/optional_nav" s:append="header" s:if="$expression" />It also fixes defining blocks from partials which was partially implemented but never finished.
- fix: allow s:block in partials to define blocks for parent layout by @josbeir in #32
- feat: include block combo by @josbeir in #33
Full Changelog: 0.6.0...0.6.1
0.6.0
v0.6.0 — Slot Outlet Tag Swapping & Attribute Merging
Named slot outlets now support tag swapping and attribute merging. When a caller fills a named slot, the caller's tag replaces the outlet's tag and attributes are merged — class values concatenate, other attributes override.
<!-- Component: <h2 s:slot="title" class="card-title">Default</h2> -->
<!-- Caller: <h3 s:slot="title" class="text-lg">My Title</h3> -->
<!-- Result: <h3 class="card-title text-lg">My Title</h3> -->Fragment outlets (<s-template s:slot="name">) inject content without a wrapper. Slot variables are still supported.
Breaking Changes
SlotOutletResolverremoved (was dead code)ComponentRenderer::$slotAttributeNameno longer has a default — always derived fromDirectivePrefixHelper
0.5.2
What's Changed
This release introduces a Vite extension and an s:block directive which can be used to check if a block from a child template has been defined on an higher inherited parent.
- feat: add Vite extension for Sugar templates by @josbeir in #29
- feat(inheritance): add
s:ifblockfor conditional block-aware rendering by @josbeir in #30
Read the docs for more information.
Full Changelog: 0.5.1...0.5.2
0.5.1
0.5.0
Breaking Changes
DirectiveType::CONTENTrenamed toDirectiveType::OUTPUT— affects any custom directive that returns this type fromgetType(). Update accordingly. (#26)SugarExceptionconstructor signature changed — now follows the standard PHPExceptionconstructor(string $message, int $code, ?Throwable $previous). Template location is no longer set via constructor arguments; use->withLocation(path, line, column)instead. Custom exception subclasses may need updating.DependencyTracker::addComponent()removed — replaced byaddDependency(). (#25)- Template inheritance is now runtime-driven — the inheritance compilation and runtime pipeline was significantly restructured. (#24)
New Features
-
usestatement hoisting (#23) — PHPuseimports in template blocks are now extracted, deduplicated, and hoisted to the top of compiled output. Supports grouped, aliased, and comma-separated forms.- New AST node:
PhpImportNode - New compiler components:
PhpImportExtractor,PhpImportRegistry
- New AST node:
-
Inheritance runtime pipeline (#24) —
s:extends,s:block,s:append,s:prepend,s:parent, ands:includeare now fully runtime-driven with dedicated block management services. Compiled output is more readable with normalized/aliased runtime helper references.
Improvements
- Unified dependency tracking (#25) —
componentsmetadata removed from cache. All template and component file dependencies now tracked through a singledependencieslist, simplifying cache invalidation logic. - Self-closing component fix — components using self-closing syntax are now handled correctly.
Internal / Refactors
DirectiveType::OUTPUTvariable naming propagated throughoutDirectiveExtractionPass($outputDirective,$outputCount, error messages), removing thecontent/outputterminology mismatch.SugarExceptionnow adheres to the standard PHP exception pattern, making Rector'sThrowWithPreviousExceptionRectorcompatible.UnknownDirectiveExceptionuses acreate()static factory.