Skip to content

Instantly share code, notes, and snippets.

@scottdavis
Created August 17, 2016 19:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scottdavis/a5541613bd7e0fc91c63987b53b88c81 to your computer and use it in GitHub Desktop.
Save scottdavis/a5541613bd7e0fc91c63987b53b88c81 to your computer and use it in GitHub Desktop.
@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