Jon Nichols
Jon Nichols

Reputation: 2351

LESS css syntax error when referencing variable from namespace

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.

Upvotes: 3

Views: 2478

Answers (1)

Evan Davis
Evan Davis

Reputation: 36592

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.

Upvotes: 5

Related Questions