I try to pass all my workflow from Sass to Stylus, but I can not convert a function.
Here is the function in sass
@mixin setIconInclude($icon) {
@each $s in $ws_icon-list {
@if nth($s, 1) == $icon {
content: nth($s, 2);
}
}
}
I tried this in Stylus but it does not work
setIconInclude($icon)
for $s in $ws_icon-list
if foo $s 0 == icon
content foo $s 1
Edit:
I have a list of icons that I define in another file.
$ws_icon-list = "iconName1" "\f105",
"iconName2" "\e81f",
"iconName3" "\e820"
With the function I'm trying to achieve, I'd like to be able to access it (the SASS function works) in Stylus but I can not understand the syntax.
$icon
is the first param of the icon I want to use as defined in the list.
You can use $s[0]
and $s[1]
instead of nth($s, 1)
and nth($s, 2)
, because Stylus lists are zero-based:
$ws_icon-list = "iconName1" "\f105",
"iconName2" "\e81f",
"iconName3" "\e820"
setIconInclude($icon)
for $s in $ws_icon-list
if $s[0] == $icon
content: $s[1]
body
setIconInclude('iconName1')