test_css_variable_machine_extraction() — tailwindcss Function Reference
Architecture documentation for the test_css_variable_machine_extraction() function in css_variable_machine.rs from the tailwindcss codebase.
Entity Profile
Dependency Diagram
graph TD 7f85dd8b_b2e9_0ca9_b066_517adca57b15["test_css_variable_machine_extraction()"] 268529ba_4bf9_7a41_0273_72baf0f193f0["css_variable_machine.rs"] 7f85dd8b_b2e9_0ca9_b066_517adca57b15 -->|defined in| 268529ba_4bf9_7a41_0273_72baf0f193f0 style 7f85dd8b_b2e9_0ca9_b066_517adca57b15 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
crates/oxide/src/extractor/css_variable_machine.rs lines 133–213
fn test_css_variable_machine_extraction() {
for (input, expected) in [
// Simple variable
("--foo", vec!["--foo"]),
("--my-variable", vec!["--my-variable"]),
// Multiple variables
(
"calc(var(--first) + var(--second))",
vec!["--first", "--second"],
),
// Variables with... emojis
("--😀", vec!["--😀"]),
("--😀-😁", vec!["--😀-😁"]),
// Escaped character in the middle, skips the next character
(r#"--spacing-1\/2"#, vec![r#"--spacing-1\/2"#]),
// Escaped whitespace is not allowed
(r#"--my-\ variable"#, vec![]),
// --------------------------
//
// Exceptions
// Not a valid variable
("", vec![]),
("-", vec![]),
("--", vec![]),
] {
for wrapper in [
// No wrapper
"{}",
// With leading spaces
" {}",
// With trailing spaces
"{} ",
// Surrounded by spaces
" {} ",
// Inside a string
"'{}'",
// Inside a function call
"fn({})",
// Inside nested function calls
"fn1(fn2({}))",
// --------------------------
//
// HTML
// Inside a class (on its own)
r#"<div class="{}"></div>"#,
// Inside a class (first)
r#"<div class="{} foo"></div>"#,
// Inside a class (second)
r#"<div class="foo {}"></div>"#,
// Inside a class (surrounded)
r#"<div class="foo {} bar"></div>"#,
// Inside an arbitrary property
r#"<div class="[{}:red]"></div>"#,
// --------------------------
//
// JavaScript
// Inside a variable
r#"let classes = '{}';"#,
// Inside an object (key)
r#"let classes = { '{}': true };"#,
// Inside an object (no spaces, key)
r#"let classes = {'{}':true};"#,
// Inside an object (value)
r#"let classes = { primary: '{}' };"#,
// Inside an object (no spaces, value)
r#"let classes = {primary:'{}'};"#,
// Inside an array
r#"let classes = ['{}'];"#,
] {
let input = wrapper.replace("{}", input);
let actual = CssVariableMachine::test_extract_all(&input);
if actual != expected {
dbg!(&input);
}
assert_eq!(actual, expected);
}
}
}
Domain
Subdomains
Source
Frequently Asked Questions
What does test_css_variable_machine_extraction() do?
test_css_variable_machine_extraction() is a function in the tailwindcss codebase, defined in crates/oxide/src/extractor/css_variable_machine.rs.
Where is test_css_variable_machine_extraction() defined?
test_css_variable_machine_extraction() is defined in crates/oxide/src/extractor/css_variable_machine.rs at line 133.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free