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

Support to interpolation to rules name #696

Closed
rentalhost opened this issue Mar 9, 2012 · 3 comments
Closed

Support to interpolation to rules name #696

rentalhost opened this issue Mar 9, 2012 · 3 comments

Comments

@rentalhost
Copy link

I closed the old topic to make it more specific.

Currently LESS have support to string interpolation and scape for values. It's possible make it work on rules name?
For instance:

@name: "span";
~".@{name}" { font-size: 12px; }

Resulting in:

.span { font-size: 12px; }

So, finally, we can do it work:

@columns: 12;

.span-n(@i) when (@i < @columns + 1) {
  ~".span@{i}" {
    width: 60px * @i;
  }

  .span-n(@i + 1);
}

.span-n(@i) {
}

.span-n(1);

Resulting in:

.span1 { width: 60px; }
.span2 { width: 120px; }
...

It's very useful to make LESS more flexible on variables. For instance: you will can configure a namespace for a project, like:

@namespace: "base";

...
~"#@{namespace}" {
  // content
}
@mrcljx
Copy link
Contributor

mrcljx commented Mar 9, 2012

I think that 93b23d2 (5 days ago) just fixed that. Either use the master-branch or wait for the nest release to use that feature.

@rentalhost
Copy link
Author

Wow! Perfect!!! Thanks!

@jkd77
Copy link

jkd77 commented May 1, 2012

// how come we can't do (note @x):

.span-n(@x, @i) when (@i < @columns + 1) {
~".span@{i}" {
width: 60px * @i;
}

.span-n(@i + 1);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants