{"id":13393233,"url":"https://github.com/JuneKelly/sneeze","last_synced_at":"2025-03-13T19:31:30.687Z","repository":{"id":47408048,"uuid":"69482004","full_name":"JuneKelly/sneeze","owner":"JuneKelly","description":"Render Elixir data-structures to HTML, inspired by Hiccup.","archived":false,"fork":false,"pushed_at":"2023-10-31T21:17:27.000Z","size":57,"stargazers_count":59,"open_issues_count":2,"forks_count":8,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-03T20:59:49.589Z","etag":null,"topics":["elixir","elixir-lang"],"latest_commit_sha":null,"homepage":"","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JuneKelly.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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}},"created_at":"2016-09-28T16:23:07.000Z","updated_at":"2024-09-23T13:50:23.000Z","dependencies_parsed_at":"2022-08-23T09:20:26.090Z","dependency_job_id":"c5409184-be19-418d-9362-7e43d0b5ae9e","html_url":"https://github.com/JuneKelly/sneeze","commit_stats":{"total_commits":68,"total_committers":3,"mean_commits":"22.666666666666668","dds":"0.044117647058823484","last_synced_commit":"769f4b2db429a87a325c3fe494fcfeb17e3d93ef"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JuneKelly%2Fsneeze","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JuneKelly%2Fsneeze/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JuneKelly%2Fsneeze/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JuneKelly%2Fsneeze/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JuneKelly","download_url":"https://codeload.github.com/JuneKelly/sneeze/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243469150,"owners_count":20295695,"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","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":["elixir","elixir-lang"],"created_at":"2024-07-30T17:00:46.851Z","updated_at":"2025-03-13T19:31:28.728Z","avatar_url":"https://github.com/JuneKelly.png","language":"Elixir","funding_links":[],"categories":["Templating","Elixir"],"sub_categories":[],"readme":"# Sneeze\n\nRender Elixir data-structures to HTML. Inspired by [Hiccup](https://github.com/weavejester/hiccup).\n\n\n## Installation\n\nSneeze is available from [Hex.pm](https://hex.pm/packages/sneeze):\n\n```elixir\ndef deps do\n  [{:sneeze, \"~\u003e 2.0\"}]\nend\n```\n\n\n## Usage\n\nThe `Sneeze.render/1` function will render a list of 'nodes' to html. A node can be any of:\n\n- A tag: `[:br]`\n- A tag with a body: `[:p, \"hello\"]`\n- A tag with attributes: `[:input, %{type: \"text\", class: \"form-field\", name: \"widget-input\"}]`\n- A tag with attributes and a body: `[:p, %{class: \"article-content\"}, \"hello\"]`\n- A bare, stringable node: `22`\n- A \"raw html\" node, which will not be escaped: `[:__@raw_html, \"\u003cspan\u003ederp\u003c/span\u003e\"]`\n\nOf course, the `body` of any node can be an arbitrary number of other nodes, like so:\n`[:p, %{id: \"status\"}, [:span, \"woo\"]]`\n\nThe `Sneeze.render_iodata/1` function returns an iodata list, which can be more performant in cases where you are passing the result to a function that accepts iodata.\n\n\n## Examples\n\n```elixir\nSneeze.render([:p %{class: \"greeting\"} \"hello world\"])\n# =\u003e \u003cp class=\"greeting\"\u003ehello world\u003c/p\u003e\n\nSneeze.render([:br])\n# =\u003e \u003cbr /\u003e\n\nSneeze.render([:span, \"\u003ca\u003ewill be escaped\u003c/a\u003e\"])\n# =\u003e \u003cspan\u003e\u0026lt;a\u0026gt;will be escaped\u0026lt;/a\u0026gt\u003c/span\u003e;\n\nSneeze.render([:div, [:__@raw_html, \"\u003cspan\u003etotally not escaped\u003c/span\u003e\"]])\n# =\u003e \u003cdiv\u003e\u003cspan\u003etotally not escaped\u003c/span\u003e\u003c/div\u003e\n\nSneeze.render(\n  [:ul, %{class: \"super-cool-list\"},\n   [:li,\n    [:a, %{href: \"/\"},        \"Home\"]],\n   [:li,\n    [:a, %{href: \"/about\"},   \"About\"]],\n   [:li,\n    [:a, %{href: \"/contact\"}, \"Contact\"]]]\n)\n# =\u003e \u003cul class=\"super-cool-list\"\u003e\u003cli\u003e\u003ca href=\"/\"\u003eHome\u003c/a\u003e\u003c/li\u003e...\u003c/ul\n\nSneeze.render([\n  [:__@raw_html, \"\u003c!DOCTYPE html\u003e\"],\n  [:head,\n   [:title, \"wat\"]],\n  [:body,\n   [:div, %{id: \"main-content\"}, \"hello\"]]\n]\n# =\u003e \u003c!DOCTYPE html\u003e\u003chead\u003e\u003ctitle\u003ewat\u003c/title\u003e\u003c/head\u003e\u003cbody\u003e\u003cdiv id=\"main-content\"\u003ehello\u003c/div\u003e\u003c/body\u003e\n\nSneeze.render_iodata([:a, %{href: \"example.com\"}, \"hello\"])\n# =\u003e [\n#      [\"\u003c\", \"a\", [[\" \", \"href\", \"=\\\"\", \"example.com\", \"\\\"\"]], \"\u003e\"],\n#      [[\"hello\"]],\n#      [\"\u003c/\", \"a\", \"\u003e\"]\n#    ]\n```\n\nIf you're using sneeze and getting surprising/screwy results, please [open an issue](https://github.com/JuneKelly/sneeze/issues).\n\n\n## Documentation\n\nDocumentation can be found on [hexdocs](https://hexdocs.pm/sneeze/).\n\n\n## Demo App\n\nSee [cold](https://github.com/JuneKelly/cold-sneeze) for a demo of how to use Sneeze with Plug.\n\n\n## Bugs, Improvements and Contributing\n\nOpen an issue or pull-request on [GitHub](https://github.com/JuneKelly/sneeze), all contributions welcome! :)\n\n\n## Changes\n\n### 2.0.0\n\n- Improved performance! (https://github.com/JuneKelly/sneeze/pull/19)\n- Attributes are now sorted before being rendered. This fixes an issue found when upgrading to OTP 26 (https://github.com/JuneKelly/sneeze/issues/17)\n\n\n### 1.3.0\n\n- A new `Sneeze.render_iodata/1` function\n- Various modernizations, dependency upgrades\n\n\n### 1.2.1\n\n- Upgrade `html_entities`\n\n\n### 1.2.0\n\n- Add `html_entities` to application list\n\n\n### 1.1.0\n\n- Better performance, using iolists instead of string-concatination\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FJuneKelly%2Fsneeze","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FJuneKelly%2Fsneeze","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FJuneKelly%2Fsneeze/lists"}