1

I have a mixin in LESS that has two variables as perimeters and that has to output a PX and a REM value.

This is the mixin:

.rem (@attr, @val) {
 @{attr}: @val * 1px;
 @{attr}: (@val * 1rem) / @baseFontSize;
}

With the @baseFontSize: 10;

If i write something like

.foo { .rem(margin, 1 2); }

I want it to output

.foo {
 margin: 1px 2px;
 margin: 0.1rem 0.2rem;
}

It works when the @val is only one value. How can i add the 'px' and 'rem' to every space separated value?

  • See examples in comments to http://stackoverflow.com/questions/35236279. – seven-phases-max Feb 18 '16 at 16:07
  • 1
    @seven-phases-max: Judging by how soon a second question has been asked, I think you should post it as an answer in one of the threads (albeit, indicating why it is not advisable to use mixins). If you don't, I am going to post one on your behalf :P (just kidding with that last sentence) – Harry Feb 18 '16 at 16:45
  • 2
    @Harry, I guess you're right. I'll post the answer there (just by copypasting the comments, please feel free to edit/expand it). – seven-phases-max Feb 19 '16 at 03:36
  • Sadly they have not released the `less-plugin-lists` [update](https://github.com/seven-phases-max/less-plugin-lists/blob/dev/test/less/va.less) yet, otherwise another answer would be just "with the plugin the code will work as is". – seven-phases-max Feb 19 '16 at 05:07

0 Answers0