less/less.ruby

Mixins first class citizens

Closed this issue · 2 comments

I come from a background in C++ and Haskell and have a fair understanding of meta template programming. To my understanding a mixin is a simple macro that supports recursive capabilities. However this in my opinion isn't really powerful enough. I suggest a minor change, that being that a mixin is a value. Currently the system supports this:

.spanX (@index) when (@index > 0) {
    ~".span@{index}" { .span(@index); }
    #grid .spanX(@index - 1);
  }
  .spanX (@index, child) when (@index > 0) {
    ~"> .span@{index}" { .span(@index); }
    #grid .spanX(@index - 1, child);
  }

However why can't I do something like?

.fn(@a) {
    .@{a} {
       color: #FFFFFF;
   }
}
.map(&fn, "class", "class2");

This mainly could be used by vendor makers, I don't expect it would be in common use but it adds so much power to less.

What's the output of the second block?