Skip to content

Support &:extend #498

Open
Open

Description

@bluetidepro

NOTE: I saw some other issues similar to this, but wasn't sure on a clear answer on when this is being added or if they were asking for the same thing.

I just updated to lessphp v0.4.0 and it looks like it doesn't support &:extend because I get the error parse error: failed at '&:extend(.foo);'

&:extend was added way back when: https://github.com/less/less.js/blob/master/CHANGELOG.md#140-beta-1--2

Here is some examples of how it works (which is actually different than mixins, sometimes people think they are the same which isn't true)

LESS:

.foo {
  color: red;
}
.bar {
  &:extend(.foo);
}

LESS output:

.foo,
.bar {
  color: red;
}

Notable about LESS extend is that it doesn't extend nested selectors by default. So if we do this:

.module {
  padding: 10px;
  h3 {
    color: red; 
  }
}

.news {
  &:extend(.module);
}

The h3 will not be extended, and will output:

.module,
.news {
  padding: 10px;
}
.module h3 {
  color: red;
}

However, if you add the all keyword, like:

.news {
  &:extend(.module all);
}

It will extend everything:

.module,
.news {
  padding: 10px;
}
.module h3,
.news h3 {
  color: red;
}

(You can also specify a nested selector to extend in place of the all keyword.)

You can find more info here: http://css-tricks.com/the-extend-concept/

Activity

  1. bluetidepro commented on Jan 10, 2014

    @bluetidepro
    Author

    It would be great to get this feature in the build! Any update by any chance?

  2. mishal commented on Jan 10, 2014

    @mishal

    Hi there!

    I want to invite you to the iless - https://github.com/mishal/iless project which solves those issues. I created the parser based on the work of Matt Agar, Martin Jantosovic and Josh Schmidt. Currently looking for testers to hunt any bugs and release a stable version. The current version compiles bootstrap2 and 3 and has many usefull features.

    Thank you

  3. dav-m85 commented on Mar 31, 2015

    @dav-m85

    +1 would be great

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions