Packages

WebAssembly is a web DSL for Elixir. You create html structure straight using do blocks. Means, you can intermix html-building blocks with full Elixir syntax. DSL output is an iolist, which you can flatten to string, but better use is to just feed it to the socket (via Plug & Cowboy). WebAssem...

Current section

Files

Jump to
webassembly lib tools.ex
Raw

lib/tools.ex

defmodule WebAssembly.Tools do
alias WebAssembly.Core.Types, as: T
@spec htmlize_attrs(T.attrs) :: [String.t]
def htmlize_attrs(attrs) do
Enum.map(attrs, fn {k,v} ->
k = k |> to_string |> String.replace("_", "-")
~s/#{k}="#{v}"/
end)
|> Enum.intersperse(" ")
end
@spec flush(T.out_tag) :: String.t
def flush(chunks) when is_list(chunks) do
chunks |> List.flatten |> Enum.join
end
# flush/1 needed only for plug-free tests, because patched Plug
# accepts iolist as a resp body
end