Skip to content

Class names adjacent to [ and ] delimiters not extracted #20233

@nicomen

Description

@nicomen

tailwind-tt-repro.zip

What version of Tailwind CSS are you using?

v4.1.8

What build tool (or framework if it abstracts the build tool) are you using?

tailwindcss CLI (standalone binary)

What version of Node.js are you using?

N/A — using the standalone Tailwind CLI binary, not Node.js (22.22.1)

What browser are you using?

Vivaldi

What operating system are you using?

Linux

Reproduction URL

Minimal reproduction attached as a zip: [tailwind-tt-repro.zip]

template.tx:

  <div class="[% IF $is_open %]bg-white/40[% ELSE %]bg-white/10[% END %]"></div>
  <div class="bg-blue-500"></div>

app.css:

  @import "tailwindcss";
  @source "./template.tx";

Run tailwindcss -i app.css -o out.css — bg-white/40 and bg-white/10 are absent from out.css, but bg-blue-500 is present.

Describe your issue

The oxide scanner does not treat [ and ] as word boundaries, so class names immediately adjacent to [% %]-style template tags are not extracted.

Template engines that use [% %] delimiters include Template Toolkit (Perl), Text::Xslate (Perl), Template::Tiny (Perl), and ExpressionEngine (PHP). In these templates, conditional
class names look like:

<div class="[% IF cond %]bg-white/40[% ELSE %]bg-white/10[% END %]">

The scanner sees %]bg-white/40[% as one token because [ and ] are not boundary characters, so neither class is extracted.

By contrast, ERB/EJS templates using <% %> work correctly because < and > are already treated as boundaries. The {/} boundary fix landed in #17001. Adding [/] as boundaries would fix this consistently.

Workarounds (both are unpleasant):

  1. @source inline("bg-white/10 bg-white/20 bg-white/40 ...") — must be kept in sync manually
  2. A pre-processing script that strips [% ... %] tags to a clean file before scanning — requires a parallel watcher process alongside tailwindcss --watch

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions