How do I convert number to words while looping in LESS? -


i exploring way convert numbers in words while looping through less.

right have following code

.margin(@n, @i:1) when (@i <= @n) {   .space-@{i} {     margin: 0rem+ @i ;   }   .space-@{i}-top {     margin-top: 0rem + @i ;   }   .space-@{i}-bottom {     margin-top: 0rem + @i ;   }   .margin(@n, (@i+1)); }  .margin(2);  

which produces:

.space-1 {   margin: 1rem; } .space-1-top {   margin-top: 1rem; } .space-1-bottom {   margin-top: 1rem; } .space-2 {   margin: 2rem; } .space-2-top {   margin-top: 2rem; } .space-2-bottom {   margin-top: 2rem; } 

however, wanted achieve class names space-one instead space-1 , on.

how utilize array in less? thanks.

see extract function. e.g.

@names:     one,     two,     three,     four,     five;  .margin(3); .margin(@i: 1) when (@i > 0) {     .margin(@i - 1);     @name: extract(@names, @i);     .space-@{name} {         margin: @i * 1rem;     } } 

Comments

Popular posts from this blog

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -