{"id":15056308,"url":"https://github.com/nayibor/ehtml","last_synced_at":"2026-04-08T14:32:11.389Z","repository":{"id":241617096,"uuid":"806819300","full_name":"nayibor/ehtml","owner":"nayibor","description":"erlang library for converting erlang,elixir terms into html and vice-versa","archived":false,"fork":false,"pushed_at":"2024-08-05T22:11:40.000Z","size":31,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-01-01T14:36:42.793Z","etag":null,"topics":["dsl","elixir","erlang","html","lfe"],"latest_commit_sha":null,"homepage":"","language":"Erlang","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nayibor.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-05-28T01:10:44.000Z","updated_at":"2024-11-29T12:04:42.000Z","dependencies_parsed_at":"2024-05-29T09:49:44.409Z","dependency_job_id":"095ab22e-4664-4e81-b6ec-6ccc2b57925e","html_url":"https://github.com/nayibor/ehtml","commit_stats":null,"previous_names":["nayibor/ehtml"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/nayibor/ehtml","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nayibor%2Fehtml","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nayibor%2Fehtml/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nayibor%2Fehtml/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nayibor%2Fehtml/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nayibor","download_url":"https://codeload.github.com/nayibor/ehtml/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nayibor%2Fehtml/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31559782,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-08T14:31:17.711Z","status":"ssl_error","status_checked_at":"2026-04-08T14:31:17.202Z","response_time":54,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["dsl","elixir","erlang","html","lfe"],"created_at":"2024-09-24T21:49:50.881Z","updated_at":"2026-04-08T14:32:11.366Z","avatar_url":"https://github.com/nayibor.png","language":"Erlang","funding_links":[],"categories":[],"sub_categories":[],"readme":"ehtml\n=====\n\nAn OTP library for simple erlang term representation of html.\nthe library converts erlang terms to and from html.\n\nit's a thin wrapper around a popular erlang web server api for \nconversion of erlang terms to html and vice versa.\n\nerlang to html\n=====\nto convert erlang to html you use the `ehtml:ehtml_expand/1` function.\n\nyou can use the rules below for the construction of the erlang terms.\n\n```erlang\n%% ------------------------------------------------------------\n%% simple erlang term representation of HTML:\n%% EHTML = [EHTML] | {Tag, Attrs, Body} | {Tag, Attrs} | {Tag} |\n%%         {Module, Fun, [Args]} | fun/0 |\n%%         binary() | character()\n%% Tag   = atom()\n%% Attrs = [{Key, Value}]\n%% Key   = atom()\n%% Value = string() | binary() | atom() | integer() | float() |\n%%         {Module, Fun, [Args]} | fun/0\n%% Body  = EHTML\n```\n\nerlang examples\n=====\n```erlang\n%% for constructing a simple table element\n36\u003e ehtml:ehtml_expand({table}).\n\"\u003c\",\"table\",[\"\u003e\u003c/\",\"table\",\"\u003e\"]]\n\n%% for constructing a div with a body\n37\u003e ehtml:ehtml_expand({'div',[],\u003c\u003c\"this is the body of the div\"\u003e\u003e}).\n[\"\\n\",\"\u003c\",\"div\",[],\"\u003e\",\u003c\u003c\"this is the body of the div\"\u003e\u003e,\n\"\u003c/\",\"div\",\"\u003e\"] \n\n%% for constructing a div with binary attributes and body\n38\u003e ehtml:ehtml_expand({'div',[{name,\u003c\u003c\"div\"\u003e\u003e},{id,\u003c\u003c\"id\"\u003e\u003e}],\u003c\u003c\"this is the body of the div\"\u003e\u003e}). \n[\"\\n\",\"\u003c\",\"div\", \n [\" name\",[61,34,\u003c\u003c\"div\"\u003e\u003e,34],\" id\",[61,34,\u003c\u003c\"id\"\u003e\u003e,34]],\n \"\u003e\",\u003c\u003c\"this is the body of the div\"\u003e\u003e,\"\u003c/\",\"div\",\"\u003e\"] \n\n%% for constructing a simple table element with attributes\n40\u003e ehtml:ehtml_expand({table,[{name,\"name\"},{id,\"id\"}]}).\n[\"\\n\",\"\u003c\",\"table\",\n [\" name\",[61,34,\"name\",34],\" id\",[61,34,\"id\",34]],\n [\"\u003e\u003c/\",\"table\",\"\u003e\"]]\n\n%% for constructing a simple table element with attributes and a body\n41\u003e Table_body = lists:map(fun(X)-\u003e {tr,[],X} end,lists:seq(1,5) ). \n[{tr,[],1},{tr,[],2},{tr,[],3},{tr,[],4},{tr,[],5}] \n42\u003e ehtml:ehtml_expand({table,[{name,\"name\"},{id,\"id\"}],Table_body}).\n[\"\\n\",\"\u003c\",\"table\", \n [\" name\",[61,34,\"name\",34],\" id\",[61,34,\"id\",34]],\n  \"\u003e\", \n [[\"\\n\",\"\u003c\",\"tr\",[],\"\u003e\",1,\"\u003c/\",\"tr\",\"\u003e\"], \n  [\"\\n\",\"\u003c\",\"tr\",[],\"\u003e\",2,\"\u003c/\",\"tr\",\"\u003e\"],\n  [\"\\n\",\"\u003c\",\"tr\",[],\"\u003e\",3,\"\u003c/\",\"tr\",\"\u003e\"], \n  [\"\\n\",\"\u003c\",\"tr\",[],\"\u003e\",4,\"\u003c/\",\"tr\",\"\u003e\"], \n  [\"\\n\",\"\u003c\",\"tr\",[],\"\u003e\",5,\"\u003c/\",\"tr\",\"\u003e\"]],\n \"\u003c/\",\"table\",\"\u003e\"]\n```\n\nelixir examples\n=====\n```elixir\n%% for constructing a simple paragraph element\niex(10)\u003e :ehtml.ehtml_expand({:p}) \n[~c\"\u003c\", ~c\"p\", [~c\"\u003e\u003c/\", ~c\"p\", ~c\"\u003e\"]]\n\n%% for constructing a div with attributes and body\niex(14)\u003e :ehtml.ehtml_expand({:div,[{:name,\"div\"},{:id,\"div\"}],\"this is my body\"}) \n[ \n ~c\"\\n\",\n  ~c\"\u003c\", \n  ~c\"div\",\n  [~c\" name\", [61, 34, \"div\", 34], ~c\" id\", [61, 34, \"div\", 34]],\n ~c\"\u003e\",\n  \"this is my body\",\n  ~c\"\u003c/\", \n  ~c\"div\", \n  ~c\"\u003e\" \n]\n\n%% for constructing a table with attributes and a body\niex(20)\u003e :ehtml.ehtml_expand({:table,[{:name,\"table\"},{:id,\"table\"}],Enum.map(1 .. 10,fn(x)-\u003e {:tr,[],x} end)})\n[\n  ~c\"\\n\", \n  ~c\"\u003c\",\n  ~c\"table\",\n  [~c\" name\", [61, 34, \"table\", 34], ~c\" id\", [61, 34, \"table\", 34]],\n  ~c\"\u003e\",\n  [\n    [~c\"\\n\", ~c\"\u003c\", ~c\"tr\", [], ~c\"\u003e\", 1, ~c\"\u003c/\", ~c\"tr\", ~c\"\u003e\"],\n    [~c\"\\n\", ~c\"\u003c\", ~c\"tr\", [], ~c\"\u003e\", 2, ~c\"\u003c/\", ~c\"tr\", ~c\"\u003e\"],\n    [~c\"\\n\", ~c\"\u003c\", ~c\"tr\", [], ~c\"\u003e\", 3, ~c\"\u003c/\", ~c\"tr\", ~c\"\u003e\"],\n    [~c\"\\n\", ~c\"\u003c\", ~c\"tr\", [], ~c\"\u003e\", 4, ~c\"\u003c/\", ~c\"tr\", ~c\"\u003e\"],\n    [~c\"\\n\", ~c\"\u003c\", ~c\"tr\", [], ~c\"\u003e\", 5, ~c\"\u003c/\", ~c\"tr\", ~c\"\u003e\"],\n    [~c\"\\n\", ~c\"\u003c\", ~c\"tr\", [], ~c\"\u003e\", 6, ~c\"\u003c/\", ~c\"tr\", ~c\"\u003e\"],\n    [~c\"\\n\", ~c\"\u003c\", ~c\"tr\", [], ~c\"\u003e\", 7, ~c\"\u003c/\", ~c\"tr\", ~c\"\u003e\"],\n    [~c\"\\n\", ~c\"\u003c\", ~c\"tr\", [], ~c\"\u003e\", 8, ~c\"\u003c/\", ~c\"tr\", ~c\"\u003e\"],\n    [~c\"\\n\", ~c\"\u003c\", ~c\"tr\", [], ~c\"\u003e\", 9, ~c\"\u003c/\", ~c\"tr\", ~c\"\u003e\"],\n    [~c\"\\n\", ~c\"\u003c\", ~c\"tr\", [], ~c\"\u003e\", 10, ~c\"\u003c/\", ~c\"tr\", ~c\"\u003e\"]\n  ],\n  ~c\"\u003c/\",\n  ~c\"table\",\n  ~c\"\u003e\"\n]\n\n```\n\n\nfor converting html to erlang\n-----\n```erlang\n7\u003e ehtml:h2e(\u003c\u003c\"\u003chtml\u003e\u003chead\u003e\u003ctitle\u003ehello world\u003c/title\u003e\u003c/head\u003e\u003cbody\u003e\u003cp\u003ehello world\u003c/p\u003e\u003c/body\u003e\u003c/html\u003e\"\u003e\u003e).\n{ehtml,[], \n\t[{html,[], \n     [{head,[],{title,[],\"hello world\"}},\n         {body,[],{p,[],\"hello world\"}}]}]}  \t \n8\u003e \n99\u003e ehtml:h2e(\u003c\u003c\"\u003cp\u003e\u003ch1 name=\\\"header\\\" id=\\\"header\\\"\u003eheader1\u003c/h1\u003e\u003c/p\u003e\"\u003e\u003e).\n{ehtml,[],\n    [{p,[],{h1,[{name,\"header\"},{id,\"header\"}],\"header1\"}}]}\n\n```\n\n\n\nBuild\n-----\n` $ rebar3 compile`\n\n` $ mix compile`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnayibor%2Fehtml","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnayibor%2Fehtml","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnayibor%2Fehtml/lists"}