SASS : Check if a variable is a map
Asked Answered
G

1

9

Is there something like is-map($some_variable) in SASS?

I have tried looking into the documentation but there is none there.

Greenleaf answered 20/8, 2016 at 10:1 Comment(0)
A
22

You can implement it with the type-of function, like this one:

@function is-map($var){
  @return type-of($var) == 'map';
}
Ameliorate answered 20/8, 2016 at 19:36 Comment(2)
And if $var is map and you need to check if map-get($var, $key) is map?Pentomic
map-get($var, $key) == 'map'Physiognomy

© 2022 - 2024 — McMap. All rights reserved.