Add Twig pre-processor#20198
Conversation
Confidence Score: 5/5Safe to merge — the pre-processor only substitutes characters in place (output length is always equal to input length), and the bracket-depth guard logic is correct. The underflow concern raised in earlier review rounds is fully addressed with explicit lower-bound guards before the slice operations. The bracket-depth stack correctly handles nested CSS-variable syntax and leaves all non-addClass/removeClass parentheses untouched. Tests exercise the original bug report, nested variable syntax, multi-class arguments, false-positive avoidance (addAttribute), and real-world component markup. No files require special attention. Reviews (2): Last reviewed commit: "update changelog" | Re-trigger Greptile |
4e91e95 to
e4509af
Compare
|
Caution Review failedPull request was closed or merged during review WalkthroughThis PR adds a Twig pre-processor module that rewrites 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
This PR fixes an issue where
addClass(opacity-50)andremoveClass(opacity-50)in Twig templates isn't extracted properly.This fixes that by adding a pre-processor for
.twigfiles. This is a simple initial implementation where we drop the(and)from theaddClassandremoveClassfunctions. We don't do any special handling around escaped characters or parenthesis inside of strings. We will add them when there is a use case for it. Until then, we'll keep it simple.If the real API would've been
addClass('opacity-50')then it would've worked out of the box.A workaround you can use today is by using spaces
addClass( opacity-50 )that works as well.Fixes: #19458
Closes: #20110
Test plan
twigextraction(and)e.g.addClass(p-(--value))which should properly extarctp-(--value)