SomMeri / less4j

Less language is an extension of css and less4j compiles it into regular css. Less adds several dynamic features into css: variables, expressions, nested rules, and so on. Less was designed to be compatible with css and any correct css file is also correct less file.
145 stars 47 forks source link

CSS Guard & appender "when" not working #283

Closed twhoff closed 9 years ago

twhoff commented 9 years ago

Somewhere between 1.9.0 and 1.11.0 the "& when" appears to have stopped working:

    @my-option: true;
    .test {

        color: pink;

        & when (@my-option = true) {
            button {
                color: white;
            }
            a {
                color: blue;
            }
        }

    }
SomMeri commented 9 years ago

Thank you for the report, I will do bugfixing soon.

SomMeri commented 9 years ago

Just released 1.12.0 version should have this fixed. If it is not, please re-open the issue.

Josef-Reichardt commented 9 years ago

I think this doesn't work if it's on the top level of the less file. The example code from http://lesscss.org/features/#css-guards-feature:

& when (@my-option = true) {
  button {
    color: white;
  }
  a {
    color: blue;
  }
}

throws the following error:

Appender symbol is not allowed inside top level rulesets.
twhoff commented 9 years ago

Hi,

That's correct, Less doesn't allow then appended symbol in the root of the document as far as I know.

This isn't always ideal as sometimes it's nice to use for scoping when sharing mixins which run at the root across multiple files.

Thanks for your great work with this compiler!

Thomas

On 23 Jun 2015, at 8:58 am, CptS notifications@github.com wrote:

I think this doesn't work if it's on the top level of the less file. The example code from http://lesscss.org/features/#css-guards-feature:

& when (@my-option = true) { button { color: white; } a { color: blue; } } throws the following error:

Appender symbol is not allowed inside top level rulesets. — Reply to this email directly or view it on GitHub.

Josef-Reichardt commented 9 years ago

It's allowed by Less (see http://jsfiddle.net/qb5t3zbr/) but not by less4j.

We're using a theme which is delivered as css and less version. We want to use the less version but thats sadly impossible with less4j.

twhoff commented 9 years ago

Because of the AST implementation?

I guess it’s a shame but there are also workarounds for it, although not ideal!

Nothing is impossible ;)

On 23 Jun 2015, at 09:45, CptS notifications@github.com wrote:

It's allowed by Less (see http://jsfiddle.net/qb5t3zbr/ http://jsfiddle.net/qb5t3zbr/) but not by less4j.

We're using a theme which is delivered as css and less version. We want to use the less version but thats sadly impossible with less4j.

— Reply to this email directly or view it on GitHub https://github.com/SomMeri/less4j/issues/283#issuecomment-114394458.

SomMeri commented 9 years ago

@CptS @EightDJ I opened new issue #286 for top level appender and the fix is already on master branch.

Unfortunately, I will not be able to do release for next week and half. If you are comfortable compiling and using latest head, then you can use that before I do proper release.

twhoff commented 9 years ago

Great! Thanks very much :)

On 25 Jun 2015, at 14:33, Mária Jurčovičová notifications@github.com wrote:

@CptS https://github.com/CptS @EightDJ https://github.com/EightDJ I opened new issue #286 https://github.com/SomMeri/less4j/issues/286 for top level appender and the fix is already on master branch.

Unfortunately, I will not be able to do release for next week and half. If you are comfortable compiling and using latest head, then you can use that before I do proper release.

— Reply to this email directly or view it on GitHub https://github.com/SomMeri/less4j/issues/283#issuecomment-115235254.

Josef-Reichardt commented 9 years ago

Yeah! Thank you! :)