{"id":13508194,"url":"https://github.com/wkhere/webassembly","last_synced_at":"2025-12-12T00:14:35.806Z","repository":{"id":19714710,"uuid":"22970221","full_name":"wkhere/webassembly","owner":"wkhere","description":"Web DSL for Elixir","archived":false,"fork":false,"pushed_at":"2022-10-16T09:10:09.000Z","size":121,"stargazers_count":72,"open_issues_count":5,"forks_count":9,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-09-01T20:02:14.940Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wkhere.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-08-14T22:09:42.000Z","updated_at":"2024-12-10T10:07:48.000Z","dependencies_parsed_at":"2022-08-24T14:08:59.493Z","dependency_job_id":null,"html_url":"https://github.com/wkhere/webassembly","commit_stats":null,"previous_names":["herenowcoder/webassembly"],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/wkhere/webassembly","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wkhere%2Fwebassembly","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wkhere%2Fwebassembly/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wkhere%2Fwebassembly/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wkhere%2Fwebassembly/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wkhere","download_url":"https://codeload.github.com/wkhere/webassembly/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wkhere%2Fwebassembly/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273377155,"owners_count":25094528,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-03T02:00:09.631Z","response_time":76,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T02:00:49.501Z","updated_at":"2025-12-12T00:14:35.754Z","avatar_url":"https://github.com/wkhere.png","language":"Elixir","readme":"WebAssembly\n===========\n[![beauty inside!](http://img.shields.io/badge/beauty-inside-80b0ff.svg)](http://en.wikipedia.org/wiki/Beauty)\n[![Build Status](https://travis-ci.org/wkhere/webassembly.svg?branch=master)](https://travis-ci.org/wkhere/webassembly)\n[![Coverage Status](https://img.shields.io/coveralls/wkhere/webassembly.svg)](https://coveralls.io/r/wkhere/webassembly)\n[![hex.pm version](https://img.shields.io/hexpm/v/webassembly.svg)](https://hex.pm/packages/webassembly)\n[![hex.pm downloads](https://img.shields.io/hexpm/dt/webassembly.svg)](https://hex.pm/packages/webassembly)\n\nDSL for creating html structure straight with Elixir blocks:\n\n```Elixir\n    use WebAssembly\n    builder do\n      html do\n        head do\n          meta http_equiv: \"Content-Type\", content: \"text/html\"\n          title \"example\"\n        end\n        body do\n          div class: \"container\", id: :content do\n            ul do\n              for index \u003c- 1..3, do:\n                li \"item #{index}\"\n            end\n            random = :random.uniform(10)\n            if random == 5 do\n              text \"Lucky! You got five\"\n            end\n          end\n          span [style: \"smiling\"], \"that was nice\"\n        end\n      end\n    end\n```\n\nThis results in a deeply nested list (aka [iolist])\nwhich you can flatten or (better!) send to the socket as it is\n([via Plug \u0026 Cowboy][via-plug] for example).\n\nNow what can be concluded from the example above:\n\n* you produce HTML elements by using macros inside `builder` block\n* [non-void] element can be used with \"flat\" content argument or with a `do`-block\n* element with a `do`-block means nesting\n* inside such a `do`-block you have access to **full Elixir syntax**\n* element attributes go first (but are optional), then the content\n* attributes are Elixir keywords\n* underscores in attribute keys are translated to dash signs\n* you can omit brackets around attributes when using `do`-block,\n  but not when using flat form\n* [void] HTML elements correspond to macros with attributes only,\n  like `meta` above\n* if you want to emit just text without surrounding html tags,\n  simply use `text` macro.\n\nFor me it's beautiful. What about you?\n\n## Why?\n\n* to have views in pure Elixir, without HTML templates\n* to utilize Erlang's approach: you can feed sockets with iolists\n  instead of one big binary produced by template engine\n\nYou can possibly mix different styles: code small snippets in\nWebAssembly and feed them to your partial templates, finally using\nyour template engine to render the whole page.\n\n## Usage\n\nWebAssembly is published on [Hex], so just add `{:webassembly, \"~\u003e 0.6\"}`\nto your deps and `:webassembly` to your apps in the `mix.exs`.\n\nUsing it with [Plug] is a no-brainer - you just pass the doc to `send_resp/3`:\n\n```Elixir\ndefmodule Plugged do\n  import Plug.Conn\n  use Plug.Router\n  use WebAssembly\n\n  plug :match\n  plug :dispatch\n\n  get \"/\" do\n    doc = builder do\n      html do\n        body do\n          text \"hello from Plug!\"\n        end\n      end\n    end\n    conn\n    |\u003e put_resp_content_type(\"text/html\")\n    |\u003e send_resp(200, doc)\n  end\nend\n```\n\nAPI details are available at [hexdocs].\n\n## TDD\n\nWebAssembly aims to have 100% [test coverage][cov].\n\n## Type Safety\n\nAs for releases `0.3.0` and above WebAssembly [dialyzes][dia] with no warnings.\n\n## Thanks\n\nLoosely inspired by [Markaby].\n\n## License\n\nThe code is released under the BSD 2-Clause License.\n\n[markaby]:  http://markaby.github.io/\n[plug]:     http://hex.pm/packages/plug\n[cowboy]:   http://hex.pm/packages/cowboy\n[iolist]:   http://www.erlang.org/doc/reference_manual/typespec.html\n[hex]:      http://hex.pm\n[void]:     http://www.w3.org/TR/html5/syntax.html#void-elements\n[non-void]: http://www.w3.org/TR/html-markup/syntax.html#elements-html-syntax-list\n[hexdocs]:  http://hexdocs.pm/webassembly\n[cov]:      https://coveralls.io/r/herenowcoder/webassembly\n[dia]:      https://github.com/fishcakez/dialyze\n[via-plug]: https://github.com/herenowcoder/webassembly#usage\n","funding_links":[],"categories":["Framework Components"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwkhere%2Fwebassembly","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwkhere%2Fwebassembly","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwkhere%2Fwebassembly/lists"}