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 builder.ex
Raw

lib/builder.ex

defmodule WebAssembly.Builder do
@moduledoc """
Provide context for using the elements DSL (`WebAssembly.DSL`)
and possibly HTML macros (`WebAssembly.HTML` module).
"""
@doc ~S"""
Generate iolist from HTML elements given in a block with the DSL.
"""
# ^ todo: link to examples, eg. in `WebAssembly` doc
defmacro builder(do_block)
defmacro builder(do: body) do
quote do
import WebAssembly.DSL.Internal
WebAssembly.Core.Builder.start
with_scope do: unquote(body)
WebAssembly.Core.Builder.finish
end
end
end