less.js icon indicating copy to clipboard operation
less.js copied to clipboard

Can't reuse generated .@{name} classes as mixins

Open syam44 opened this issue 13 years ago • 3 comments

Hi,

I'm using LESS 1.3.3

When I generate classes like this:

#genMarginTop (@name, @size) {
    .@{name} { margin-top: @size; }
}
#genMarginTop(mtStandard, 60);

Then I can't reuse them as mixins even though they are perfectly usable in HTML:

.someClass { .mtStandard; /* more stuff */ }

It gives a NameError: .mtStandard is undefined

Sure I can work around that using a different generator:

#genMarginTop (@size) {
    margin-top: @size;
}
.mtStandard { #genMarginTop(60); }
.someClass { .mtStandard; /* more stuff */ }

But somehow this syntax feels clumsy, I'd rather generate the class directly using the @{name} syntax in the generator.

The problem seems to be that LESS doesn't register such generated classes in its "internal list" of available classes. It would be very nice if LESS could somehow "backtrack" those generated classes in order to be able to reuse them.

Thanks, and keep up the good work!

syam44 avatar Feb 28 '13 19:02 syam44

duplicate, see #1196

lukeapage avatar Feb 28 '13 21:02 lukeapage

p.s. thanks for the thanks!

lukeapage avatar Feb 28 '13 21:02 lukeapage

Sorry for the duplicate, even though I saw #1196 in the list I didn't understand just from its title that it was related. I'll watch that thread instead. Thanks again, for your reactivity in addition to all the rest. ;)

syam44 avatar Feb 28 '13 23:02 syam44