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
Current section
Files
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.
Code being run in the block can be split into different fuctions
(this is an equivalent of partial templates).
Builder is guaranteed to work as long as calls happen in the same
Erlang process, which is typical for the intended use (webapp
controllers/handlers).
"""
# ^ 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.Engine.fire
with_scope do: unquote(body)
WebAssembly.Core.Engine.return
end
end
end