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
Post a Comment