Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

String interpolation behaves differently in mixin and in ruleset #2094

Closed
SomMeri opened this issue Jul 5, 2014 · 2 comments
Closed

String interpolation behaves differently in mixin and in ruleset #2094

SomMeri opened this issue Jul 5, 2014 · 2 comments
Assignees

Comments

@SomMeri
Copy link
Member

SomMeri commented Jul 5, 2014

String and escaped value interpolation behavior depends on context:

  • If a mixin contains interpolated string, the interpolation iterates while possible.
  • If a ruleset contains interpolated string, the interpolation runs only once.

The same value @{box-@{suffix}} with the same scope variables available can end up either as @{box-large} or as 100px. The result depends on whether mixin was called.

The issue #1387 suggests that the interpolation should iterate.

Full example:

@box-small: 10px;
@box-large: 100px;

.mixin { // both ruleset and mixin
    width: ~"@{box-@{suffix}}";
    weird: ~"@{box}-@{suffix}}";
    @box: ~"@{box";
        @suffix: large;
}
.interpolation-mixin {
    .mixin(); //call the above as mixin
}

compiles into:

.mixin {
  width: @{box-large};
  weird: @{box-large};
}
.interpolation-mixin {
  width: 100px;
  weird: 100px;
}

Expected result:

.mixin {
  width: 100px;
  weird: 100px;
}
.interpolation-mixin {
  width: 100px;
  weird: 100px;
}
@seven-phases-max
Copy link
Member

Yes, currently the number of nested mixins calls -> number of allowed nested string interpolations:

@foobar: #69c;

.z {
    @pre:   foo;
    @post:  bar;
    @p:     p;

               @a: ~"@{@{pre}@{post}}";
  .1()        {@b: ~"@{@{pre}@{post}}"} .1;
  .2()        {@c: ~"@{@{@{p}re}@{post}}"} .2;
  .3() { .4() {@d: ~"@{@{@{p}re}@{post}}"} .4} .3;

    a:  @a;  // @{foobar}
    b:  @b;  // #6699cc
    c:  @c;  // @{foobar}
    d:  @d;  // #6699cc
}

This is because each mixin expansion evaluates mixin variables thus "removing" the top-level @{...}.

@SomMeri SomMeri self-assigned this Sep 5, 2014
SomMeri pushed a commit to SomMeri/less-rhino.js that referenced this issue Sep 5, 2014
@SomMeri
Copy link
Member Author

SomMeri commented Jan 13, 2015

This was fixed by previous commit.

@SomMeri SomMeri closed this as completed Jan 13, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants