Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LESS css syntax error when referencing variable from namespace

Tags:

less

I'm getting a syntax error when attempting to reference a variable from a namespace in LESS:

#testns {
    @my_color: #04ffff;
    .me() {
        color: blue;
    }
}

.fun {
    color: #testns[@my_color];
}

The mixin works fine if I do the following:

.fun {
    #testns > .me();
}

But I'm not able to reference the variable from the namespace for some reason. I'm building these in Java using the asual library, and everything else is working perfectly.

like image 418
Jon Nichols Avatar asked Jun 28 '26 13:06

Jon Nichols


1 Answers

This isn't how namespaces work. Namespaces allow you to declare local-scope variables to use in mixins (sort of like a CSS closure, ha!), and the mixins can be referenced from outside the namespace bundle. The variable inside the namespace are private, however, and cannot be referenced from outside the namespace.

like image 108
Mathletics Avatar answered Jul 02 '26 03:07

Mathletics



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!