defmodule FleexUi.StylesParser do @moduledoc """ Provides functions to parse style properties to a valid html style global attribute format. """ @doc """ Parses style properties map to a valid html style attribute. """ def parse(styles) do styles |> Map.delete(:__changed__) |> Enum.reduce("", fn {key, value}, acc -> case key do :bg -> add_property("background-color: ", value, acc) :width -> add_property("width: ", value, acc) :height -> add_property("height: ", value, acc) end end) end defp add_property(name, value, properties), do: name <> value <> "; " <> properties end