tailwindcss/crates/oxide/src/extractor
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
..
pre_processors Handle template toolkit %]…[% syntax (#20269) 2026-06-22 15:40:58 +02:00
arbitrary_property_machine.rs Improve performance in bigger projects (#19632) 2026-02-17 20:15:20 +01:00
arbitrary_value_machine.rs Improve performance in bigger projects (#19632) 2026-02-17 20:15:20 +01:00
arbitrary_variable_machine.rs Improve performance in bigger projects (#19632) 2026-02-17 20:15:20 +01:00
boundary.rs Ensure classes between > and < are properly extracted (#17094) 2025-03-10 11:28:08 +01:00
bracket_stack.rs Improve Oxide candidate extractor [0] (#16306) 2025-03-05 11:55:24 +01:00
candidate_machine.rs Improve performance in bigger projects (#19632) 2026-02-17 20:15:20 +01:00
css_variable_machine.rs Improve performance in bigger projects (#19632) 2026-02-17 20:15:20 +01:00
machine.rs Improve Oxide candidate extractor [0] (#16306) 2025-03-05 11:55:24 +01:00
mod.rs Handle template toolkit %]…[% syntax (#20269) 2026-06-22 15:40:58 +02:00
modifier_machine.rs Improve performance in bigger projects (#19632) 2026-02-17 20:15:20 +01:00
named_utility_machine.rs Improve performance in bigger projects (#19632) 2026-02-17 20:15:20 +01:00
named_variant_machine.rs Improve performance in bigger projects (#19632) 2026-02-17 20:15:20 +01:00
string_machine.rs Improve performance in bigger projects (#19632) 2026-02-17 20:15:20 +01:00
utility_machine.rs Improve performance in bigger projects (#19632) 2026-02-17 20:15:20 +01:00
variant_machine.rs Improve performance in bigger projects (#19632) 2026-02-17 20:15:20 +01:00