Skip to content

Add Less compiler and pre-eval AST visitors for CSS var support#365

Open
lippserd wants to merge 1 commit intomainfrom
less
Open

Add Less compiler and pre-eval AST visitors for CSS var support#365
lippserd wants to merge 1 commit intomainfrom
less

Conversation

@lippserd
Copy link
Copy Markdown
Member

@lippserd lippserd commented Apr 9, 2026

WikimediaLessCompiler wraps Less_Parser with a clean compile() API and normalizes parser exceptions into RuntimeException. PreEvalVisitor establishes a base for visitors that hook into the pre-compile() phase, receiving the raw AST before variables and mixins are resolved.

CssVarVisitor replaces every Less color variable reference with a var(--name, fallback) call, enabling runtime theming through CSS custom properties while preserving Less fallback resolution. DetachedRulesetCallVisitor expands a named detached ruleset into a configured Less template, making it possible to wrap styles in constructs like @media blocks without modifying the Less source.

The wikimedia/less.php dependency is bumped from ^3.2.1 to ^5.5 to align with the isPreEvalVisitor hook and other APIs these visitors rely on.

refs Icinga/icingaweb2#5492
refs Icinga/icinga-php-thirdparty#115

`WikimediaLessCompiler` wraps `Less_Parser` with a clean `compile()` API
and normalizes parser exceptions into `RuntimeException`. `PreEvalVisitor`
establishes a base for visitors that hook into the pre-`compile()` phase,
receiving the raw AST before variables and mixins are resolved.

`CssVarVisitor` replaces every Less color variable reference with a
`var(--name, fallback)` call, enabling runtime theming through CSS custom
properties while preserving Less fallback resolution. `DetachedRulesetCallVisitor`
expands a named detached ruleset into a configured Less template, making it
possible to wrap styles in constructs like `@media` blocks without modifying
the Less source.

The `wikimedia/less.php` dependency is bumped from `^3.2.1` to `^5.5` to
align with the `isPreEvalVisitor` hook and other APIs these visitors rely on.
@lippserd lippserd added this to the 0.14.0 milestone Apr 10, 2026
@lippserd lippserd marked this pull request as ready for review April 10, 2026 14:41
@lippserd lippserd requested a review from nilmerg April 10, 2026 14:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant