Home / Function/ test_extract_css_variables() — tailwindcss Function Reference

test_extract_css_variables() — tailwindcss Function Reference

Architecture documentation for the test_extract_css_variables() function in mod.rs from the tailwindcss codebase.

Entity Profile

Dependency Diagram

graph TD
  27af4982_35e9_a56a_38d5_79c7e4d26f18["test_extract_css_variables()"]
  eb5f3ab1_80da_abe4_f35c_a91e8e409b69["mod.rs"]
  27af4982_35e9_a56a_38d5_79c7e4d26f18 -->|defined in| eb5f3ab1_80da_abe4_f35c_a91e8e409b69
  95010e82_5328_07c4_0b6e_8d30afb5a935["assert_extract_sorted_css_variables()"]
  27af4982_35e9_a56a_38d5_79c7e4d26f18 -->|calls| 95010e82_5328_07c4_0b6e_8d30afb5a935
  style 27af4982_35e9_a56a_38d5_79c7e4d26f18 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

crates/oxide/src/extractor/mod.rs lines 1072–1136

    fn test_extract_css_variables() {
        for (input, expected) in [
            // Simple variable
            ("--foo", vec!["--foo"]),
            ("--my-variable", vec!["--my-variable"]),
            // Multiple variables
            (
                "calc(var(--first) + var(--second))",
                vec!["--first", "--second"],
            ),
            // 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![]),
        ] {
            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);

                assert_extract_sorted_css_variables(&input, expected.clone());
            }
        }
    }

Domain

Subdomains

Frequently Asked Questions

What does test_extract_css_variables() do?
test_extract_css_variables() is a function in the tailwindcss codebase, defined in crates/oxide/src/extractor/mod.rs.
Where is test_extract_css_variables() defined?
test_extract_css_variables() is defined in crates/oxide/src/extractor/mod.rs at line 1072.
What does test_extract_css_variables() call?
test_extract_css_variables() calls 1 function(s): assert_extract_sorted_css_variables.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free