mirror of
https://github.com/tailwindlabs/tailwindcss.git
synced 2025-12-08 21:36:08 +00:00
Add razor/cshtml pre processing (#17027)
This PR fixes an issue in Razor template files where `@sm:flex` doesn't work and `@@sm:flex` is required. In Tailwind CSS v3, some people used a custom transform to replace `@@` with just `@`. But in Tailwind CSS v4 we don't have this. However, we can add a pre processor for `.cshtml` and `.razor` files. Fixes: #17022
This commit is contained in:
parent
bd1e540776
commit
d18fed1dca
@ -22,6 +22,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- Ensure utilities are sorted based on their actual property order ([#16995](https://github.com/tailwindlabs/tailwindcss/pull/16995))
|
||||
- Ensure strings in Pug and Slim templates are handled correctly ([#17000](https://github.com/tailwindlabs/tailwindcss/pull/17000))
|
||||
- Ensure `}` and `{` are valid boundary characters when extracting candidates ([#17001](https://github.com/tailwindlabs/tailwindcss/pull/17001))
|
||||
- Add `razor`/`cshtml` pre processing ([#17027](https://github.com/tailwindlabs/tailwindcss/pull/17027))
|
||||
|
||||
## [4.0.11] - 2025-03-06
|
||||
|
||||
|
||||
@ -1,11 +1,13 @@
|
||||
pub mod pre_processor;
|
||||
pub mod pug;
|
||||
pub mod razor;
|
||||
pub mod ruby;
|
||||
pub mod slim;
|
||||
pub mod svelte;
|
||||
|
||||
pub use pre_processor::*;
|
||||
pub use pug::*;
|
||||
pub use razor::*;
|
||||
pub use ruby::*;
|
||||
pub use slim::*;
|
||||
pub use svelte::*;
|
||||
|
||||
27
crates/oxide/src/extractor/pre_processors/razor.rs
Normal file
27
crates/oxide/src/extractor/pre_processors/razor.rs
Normal file
@ -0,0 +1,27 @@
|
||||
use crate::extractor::pre_processors::pre_processor::PreProcessor;
|
||||
use bstr::ByteSlice;
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
pub struct Razor;
|
||||
|
||||
impl PreProcessor for Razor {
|
||||
fn process(&self, content: &[u8]) -> Vec<u8> {
|
||||
content.replace("@@", " @")
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::Razor;
|
||||
use crate::extractor::pre_processors::pre_processor::PreProcessor;
|
||||
|
||||
#[test]
|
||||
fn test_razor_pre_processor() {
|
||||
let (input, expected) = (
|
||||
r#"<div class="@@sm:text-red-500">"#,
|
||||
r#"<div class=" @sm:text-red-500">"#,
|
||||
);
|
||||
Razor::test(input, expected);
|
||||
Razor::test_extract_contains(input, vec!["@sm:text-red-500"]);
|
||||
}
|
||||
}
|
||||
@ -468,6 +468,7 @@ pub fn pre_process_input(content: &[u8], extension: &str) -> Vec<u8> {
|
||||
use crate::extractor::pre_processors::*;
|
||||
|
||||
match extension {
|
||||
"cshtml" | "razor" => Razor.process(content),
|
||||
"pug" => Pug.process(content),
|
||||
"rb" | "erb" => Ruby.process(content),
|
||||
"slim" => Slim.process(content),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user