Created
August 17, 2016 19:19
-
-
Save scottdavis/a5541613bd7e0fc91c63987b53b88c81 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@doc """ | |
Converts Elixir map into a sass map | |
""" | |
def convert_to_sass(map) when is_map(map) do | |
"(" <> Enum.map_join(map, ",", fn {k, v} -> | |
"#{convert_to_sass(k)}:#{convert_to_sass(v)}" | |
end) <> ")" | |
end | |
@doc """ | |
Converts Elixir atom into its corresponding sass value | |
""" | |
def convert_to_sass(atom) when is_atom(atom) do | |
case atom do | |
true -> "true" | |
false -> "false" | |
_ -> "'#{atom}'" | |
end | |
end | |
@doc """ | |
Converts an Elixir binary into a quoted sass string | |
""" | |
def convert_to_sass(string) when is_binary(string) do | |
"'#{string}'" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment