tailwindcss/crates
Robin Malfait d5ca0aeac9
Handle template toolkit %]…[% syntax (#20269)
This PR handles template toolkit syntax as a pre-processor step such
that `%]` and `[%` are seen as valid boundary characters.

This is handled for the `.tt`, `.tt2` and `.tx` file extensions. It's
not handled if this syntax is used in `.html` files because then
everybody pays a pre processor cost even if you don't need this syntax
in most cases.

This now ensures that a `template.tx` like this:
```html
<div class="[% IF $is_open %]bg-white/40[% ELSE %]bg-white/10[% END %]"></div>
<!--                         ^^^^^^^^^^^          ^^^^^^^^^^^              -->
```
Extracts the classes in between those conditions correctly.

This also fixes a small issue related to Maud, a template engine for
Rust where conditionals like `p.text-black[condition]` caused the
`text-black` class not to be extracted. This is fixed as part of this PR
because it was commented on the linked issue.

Fixes: #20233 

## Test plan

1. Added a new extractor
2. Added regression tests
3. All existing tests pass
2026-06-22 15:40:58 +02:00
..
classification-macros Improve boundary classification (#17005) 2025-03-07 00:00:54 +00:00
ignore Incorporate changes from latest ignore crate (#19148) 2025-10-20 09:49:40 -04:00
node Update all pnpm dependencies (2026-06-15) (#20241) 2026-06-15 13:13:32 +00:00
oxide Handle template toolkit %]…[% syntax (#20269) 2026-06-22 15:40:58 +02:00