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
Add array variable support and loop function #1465
@grid_columns: 6;
@word_numbers: one two three four five six seven eight nine ten eleven twelve;
.row {
.column_loop (@index) when (@index=1){
.one.column {
.column_width(@index);
}
}
.column_loop (@index) when(@index<@grid_columns+1){
@word: extract(@word_numbers, @index);
.@{word}.columns {
.column_width(@index);
}
.column_loop(@index+1);
}
.column_loop(1);
.column_width(@index){
width: percentage(@index/@grid_columns);
}
}
You can see the full code here.
But if you give ability get the ability of foreach loop as below. The code will be shorter and much more easy to read.
Especially i dont need use a extra @count variable any more.
Activity
lukeapage commentedon Aug 3, 2013
You can do all of this in less..
thecreation commentedon Aug 5, 2013
@lukeapage Can you give a simple example. I don't understand well. Thanks!
jonschlinkert commentedon Aug 5, 2013
this would make a good stackoverflow question.. ;-)
Soviut commentedon Aug 5, 2013
Indeed, Let Me Google That For You(TM) ;)
http://stackoverflow.com/questions/17695787/build-a-selector-within-a-less-loop
thecreation commentedon Aug 5, 2013
Good.
And it result
I think you should update the usage of extract function to the documentation.
Thanks for all the helps.
Soviut commentedon Aug 5, 2013
I've created an issue in the less-docs repository for updating the
extract()documentation. You may now close this issue.thecreation commentedon Aug 7, 2013
@Soviut thanks. I would like close this issue.
But i am still thinking it's necessary adding a foreach loop.
For example.
At the moment i have the code below:
You can see the full code here.
But if you give ability get the ability of foreach loop as below. The code will be shorter and much more easy to read.
Especially i dont need use a extra @count variable any more.
If this is not easy to achieve, i hope you can give a size function to get the size of a array variable:
Thanks again. For your open mind and your hard work.
lukeapage commentedon Sep 11, 2013
see #1542