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/examples/simple.ex
defmodule WebAssembly.Examples do
# needed to have examples as a separate module
# to trigger dialyzer analysis of core & dsl
def readme_ex do
use WebAssembly
builder do
html do
head do
meta http_equiv: "Content-Type", content: "text/html"
title "example"
end
body do
div class: "container", id: :content do
ul do
elements for index<-1..5, do:
pick li ["item ", index]
end
random = :random.uniform(10)
if random == 5 do
text "Lucky! You got five"
end
end
text "that was nice"
end
end
end
end
end