Skip to content

Support formatted Vue Pug template tags - #20475

Open
cuishuang wants to merge 1 commit into
tailwindlabs:mainfrom
cuishuang:fix/vue-pug-template-attributes
Open

Support formatted Vue Pug template tags#20475
cuishuang wants to merge 1 commit into
tailwindlabs:mainfrom
cuishuang:fix/vue-pug-template-attributes

Conversation

@cuishuang

Copy link
Copy Markdown
Contributor

Summary

Vue files are passed through the Vue preprocessor, which detects <template lang="pug"> blocks and runs the Pug preprocessor on their contents.

The existing regular expression only matched the most compact opening tag form. It missed valid Vue template tags when lang had surrounding whitespace, when the opening tag spanned multiple lines, or when other attributes were present.

This change broadens the opening-tag detection while preserving the existing body replacement behavior. Pug preprocessing now works for formatted template tags and still ignores unrelated attributes such as data-lang.

Test plan

  • cargo test -p tailwindcss-oxide
  • rustfmt --check crates/oxide/src/extractor/pre_processors/vue.rs

All Oxide and scanner tests pass.

@cuishuang
cuishuang requested a review from a team as a code owner September 10, 2026 01:55
@coderabbitai

coderabbitai Bot commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 8cddbbc1-38e4-4b2e-aa12-2995e147cffe

📥 Commits

Reviewing files that changed from the base of the PR and between 41d9cae and 2995898.

📒 Files selected for processing (1)
  • crates/oxide/src/extractor/pre_processors/vue.rs

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


Walkthrough

Vue template extraction now accepts attributes before or after lang, whitespace around =, and single- or double-quoted language values. Capture handling uses explicit lookups for the language and template body. Tests cover the supported attribute formats and confirm that data-lang does not trigger template preprocessing.

Severity of issue fixed: Low

Merge Risk: ⚪ Minimal · up to 29958

Vue Pug template preprocessing now supports formatted template attributes while preserving existing body replacement behavior and ignoring data-lang. The covered parsing cases and passing checks indicate no current merge-blocking risk.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: support for formatted Vue Pug template tags.
Description check ✅ Passed The description explains the Vue preprocessing change, supported tag formats, preserved behavior, and test commands. It is directly related to the changeset.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 4/5

The PR should not merge until template attributes are parsed without recognizing lang= inside another attribute’s value.

Reviews (1) · Last reviewed commit: "Support formatted Vue Pug template tags"

static TEMPLATE_REGEX: sync::LazyLock<Regex> = sync::LazyLock::new(|| {
Regex::new(r#"<template lang=['"]([^"']*)['"]>([\s\S]*)<\/template>"#).unwrap()
Regex::new(
r#"<template\s+(?:[^>]*\s+)?lang\s*=\s*(?:"([^"]*)"|'([^']*)')[^>]*>([\s\S]*)<\/template>"#,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Quoted values mimic lang

The [^>]* attribute scan is not aware of quoted values. For example, <template data-config=" lang='pug'"> has no real lang attribute, but this regex captures pug from inside data-config and passes the HTML body through the Pug preprocessor. That can change extracted class candidates, such as interpreting the literal HTML class foo.bar as separate Pug classes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant