You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
:extend to extend dynamically generated classes? #1325
I'm looking to extend some grid classes that are dynamically generated in Bootstrap 3.0.0.-wip.
I understand the answer to my question is no, according to this answer on SO.
(...) you need to redefine any dynamic class generations of bootstrap to be non-dynamic. Something like this:
.span3 {
.span(3);
}
This is so the :extend(.span3) will find a hard coded class to extend to. This would need to be done for any selector string that dynamically uses .span@{index} to add the .span3.
So, I may have an answer now, but not a feature :)
I understand this is possible in Sass, as that's what is done in csswizardry-grids and unsemantic, which proves useful if used in tandem with silent classes.
I've been able to somewhat "replicate" the functionality by first compiling a set of .less file (in this case, Bootstrap's grid system), and, after that, then compiling a second set of .less files (my project) which imported the first compiled set (as if they were .less files).
Technically this is a feature request for extending "non-existent" classes, since (in Less.js) dynamically generated classes can't be extended until after they are generated.
Closing since the payoff isn't enough to justify the code debt. We might reconsider after 2.0, so feel free to continue the conversation here, but I think we'll need more uses cases than this to be convinced.
Maybe a clean way to implement this could be with an option (a flag) to do a second pass?
If that flag is on, Less.js does a first pass, ignoring any :extend. On this first pass, dynamically generated classes get generated. Then Less.js does a second pass, where it just does the :extends. Hopefully this could reduce any potential code debt of trying to do everything on a single pass.
As for presenting more uses cases & arguments, I admit I will have to think a bit more to come up with some. But the basic, general one (that is: use case: to be able to :extend() dynamically generated classes) seems to go "in the spirit" of Less and CSS pre-processing in general.
Ideas are always good, I can see your point about being "in the spirit of preprocessing". Let us know if you come up with more use cases (or anyone else), or if the needs is there we will reopen anytime.
+1 for this feature
I have been using sass. I decided to use less in one of my project and now I think that I made a big mistake I will not use less next time :)
+1 for this
My case: I'm developing a grid system which is widely used in my company and I generate dynamic classes with customizable prefixes. Sadly, missing this feature, you can't extend any of the generated classes, so to apply grid styles you always have to use the classes in markup or call mixins. This feature could save a lot of duplicated code.
changed the title [-]Feature request for :extend: possible to extend dynamically generated classes?[/-][+]`:extend` to extend dynamically generated classes? (interpolated identifier + concatenated identifier + variabe inside `extend(...)`)[/+]on Sep 18, 2014
Activity
jonschlinkert commentedon May 18, 2013
Technically this is a feature request for extending "non-existent" classes, since (in Less.js) dynamically generated classes can't be extended until after they are generated.
Closing since the payoff isn't enough to justify the code debt. We might reconsider after 2.0, so feel free to continue the conversation here, but I think we'll need more uses cases than this to be convinced.
maniqui commentedon May 18, 2013
Thanks for the feedback, jonschlinkert.
Maybe a clean way to implement this could be with an option (a flag) to do a second pass?
If that flag is on, Less.js does a first pass, ignoring any
:extend. On this first pass, dynamically generated classes get generated. Then Less.js does a second pass, where it just does the:extends. Hopefully this could reduce any potential code debt of trying to do everything on a single pass.As for presenting more uses cases & arguments, I admit I will have to think a bit more to come up with some. But the basic, general one (that is: use case: to be able to :extend() dynamically generated classes) seems to go "in the spirit" of Less and CSS pre-processing in general.
jonschlinkert commentedon May 18, 2013
Ideas are always good, I can see your point about being "in the spirit of preprocessing". Let us know if you come up with more use cases (or anyone else), or if the needs is there we will reopen anytime.
lukeapage commentedon May 29, 2013
I think this should be left open?
maniqui commentedon May 29, 2013
Just posting to share another kind of dynamically generated class names that cannot be extended:
As you can see, the
.baseclass is not being extended.OrganicPanda commentedon Dec 11, 2013
I just stumbled upon this when trying to extend Font-Awesome classes which are defined like:
So using:
Doesn't work but it would be nice if it did.
vandalizmo commentedon Dec 20, 2013
+1 for that feature
jonschlinkert commentedon Dec 20, 2013
I just noticed @lukeapage's comment about reopening. sounds good
srsgores commentedon Dec 21, 2013
+1 for this. SASS has this feature, and it would put the two on more equal footing IMO
jonschlinkert commentedon Dec 27, 2013
How would this improve SASS? Lol wouldn't this make Less.js even better? jk
julien-f commentedon Jan 7, 2014
Hi, I am new to Less but I find this problem to be quite annoying too.
My use case is the same as @OrganicPanda's: I use Font-Awesome in my project and I alias some icons to more meaningful names to ease maintenance (see this code for instance).
I would like to port this project from SASS to Less but this is a blocker. 😞
IMHO, it should not matter to me whether the classes I want to extend from has been dynamically generated or not: it is an implementation detail.
At least you should put a warning concerning this behavior in the documentation.
Thank you.
julien-f commentedon Jan 7, 2014
There is a warning about this on the new documentation, my bad.
safareli commentedon Jul 3, 2014
+1 for this feature
I have been using sass. I decided to use less in one of my project and now I think that I made a big mistake I will not use less next time :)
SimonHarte commentedon Sep 10, 2014
+1 for this
My case: I'm developing a grid system which is widely used in my company and I generate dynamic classes with customizable prefixes. Sadly, missing this feature, you can't extend any of the generated classes, so to apply grid styles you always have to use the classes in markup or call mixins. This feature could save a lot of duplicated code.
lukeapage commentedon Sep 10, 2014
I will take a look at doing it on the v2 branch.
[-]Feature request for :extend: possible to extend dynamically generated classes?[/-][+]`:extend` to extend dynamically generated classes? (interpolated identifier + concatenated identifier + variabe inside `extend(...)`)[/+]seven-phases-max commentedon Sep 18, 2014
Merging to #2200 and #1485.
[-]`:extend` to extend dynamically generated classes? (interpolated identifier + concatenated identifier + variabe inside `extend(...)`)[/-][+]`:extend` to extend dynamically generated classes?[/+]