{"id":13800869,"url":"https://github.com/teropa/hiccups","last_synced_at":"2025-10-22T02:47:36.776Z","repository":{"id":61593630,"uuid":"2168216","full_name":"teropa/hiccups","owner":"teropa","description":"A ClojureScript port of Hiccup - a fast library for rendering HTML in ClojureScript","archived":false,"fork":false,"pushed_at":"2020-11-06T18:17:22.000Z","size":42,"stargazers_count":215,"open_issues_count":3,"forks_count":22,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-05-03T02:40:22.351Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"epl-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/teropa.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.html","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-08-07T09:56:28.000Z","updated_at":"2025-03-30T21:54:26.000Z","dependencies_parsed_at":"2022-10-19T23:00:20.395Z","dependency_job_id":null,"html_url":"https://github.com/teropa/hiccups","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teropa%2Fhiccups","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teropa%2Fhiccups/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teropa%2Fhiccups/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teropa%2Fhiccups/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/teropa","download_url":"https://codeload.github.com/teropa/hiccups/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253913249,"owners_count":21983287,"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":[],"created_at":"2024-08-04T00:01:17.118Z","updated_at":"2025-10-22T02:47:31.743Z","avatar_url":"https://github.com/teropa.png","language":"Clojure","readme":"Hiccups\n=======\n\nHiccups is a ClojureScript port of the [Hiccup](https://github.com/weavejester/hiccup) HTML generation library.\nIt uses vectors to represent tags, and maps to represent a tag's attributes.\n\nThe goal is to provide similar performance to Closure Templates with a much more Clojure friendly\nsyntax.\n\nDifferences from Hiccup\n-----------------------\n\n* In ClojureScript, macros need to be defined in separate Clojure namespaces. Because of this,\n  core functionality is split into two files: `core.clj` contains the macros and compile-time only\n  functions, and `runtime.cljs` contains functions that are also available at runtime. The contents\n  of `runtime.cljs` are also used at compile-time, so the goal is to keep it portable between\n  ClojureScript and Clojure.\n* Unit tests are run in a PhantomJS browser using [lein-cljsbuild](https://github.com/emezeske/lein-cljsbuild/) and Closure's testing libs.\n* Not everything has been ported yet. See ToDo.\n\nAlternatives\n------------\n\n* [Crate](https://github.com/ibdknox/crate) is an alternative Hiccup style library for ClojureScript. The main difference\n  between Crate and Hiccups is that Crate generates DOM nodes and Hiccups generates strings. There are a few reasons why you might consider Hiccups over Crate (YMMV, of course):\n  * As with the original Hiccup, Hiccups tries to do as much as possible at compile time, with macro expansion.\n  * Working with strings can be much more\n  performant than working with DOM nodes, especially with large amounts of markup, and\n  [especially with older browsers](http://www.quirksmode.org/dom/innerhtml.html).\n  * Easier to use in headless environments like Node.js\n* [Closure Templates](http://code.google.com/closure/templates/) is Google's Closure templating library.\n\nInstall\n-------\n\nAdd the following dependency to your `project.clj` file:\n\n```clojure\n[hiccups \"0.3.0\"]\n```\n\nUsage\n-----\n\nRequire both the core macros and the runtime functions in your namespace declaration:\n\n```clojure\n(ns myns\n  (:require-macros [hiccups.core :as hiccups :refer [html]])\n  (:require [hiccups.runtime :as hiccupsrt]))\n\n(hiccups/defhtml my-template []\n  [:div\n    [:a {:href \"https://github.com/weavejester/hiccup\"}\n      \"Hiccup\"]])\n```\n\nSyntax\n------\n\nHere is a basic example of Hiccups syntax:\n\n```clojure\n(html [:span {:class \"foo\"} \"bar\"])\n\"\u003cspan class=\\\"foo\\\"\u003ebar\u003c/span\u003e\"\n```\n\nThe first element of the vector is used as the tag name. The second\nattribute can optionally be a map, in which case it is used to supply\nthe tag's attributes. Every other element is considered part of the\ntag's body.\n\nHiccups is intelligent enough to render different HTML tags in different\nways, in order to accommodate browser quirks:\n\n```clojure\n(html [:script])\n\"\u003cscript\u003e\u003c/script\u003e\"\n(html [:p])\n\"\u003cp /\u003e\"\n```\n\nAnd provides a CSS-like shortcut for denoting `id` and `class`\nattributes:\n\n```clojure\n(html [:div#foo.bar.baz \"bang\"])\n\"\u003cdiv id=\\\"foo\\\" class=\\\"bar baz\\\"\u003ebang\u003c/div\u003e\"\n```\n\nIf the body of the tag is a seq, its contents will be expanded out into\nthe tag body. This makes working with forms like `map` and `for` more\nconvenient:\n\n```clojure\n(html [:ul\n        (for [x (range 1 4)]\n          [:li x])])\n\"\u003cul\u003e\u003cli\u003e1\u003c/li\u003e\u003cli\u003e2\u003c/li\u003e\u003cli\u003e3\u003c/li\u003e\u003c/ul\u003e\"\n```\n\nNote that while lists are considered to be seqs in Clojure(Script), vectors and sets are not. As a consequence, Hiccups will bail out if a vector is passed in without a tag: `[[:div] [:div]]`.\n\nSee the [Hiccup wiki](https://github.com/weavejester/hiccup/wiki) for more information.\n\nToDo\n----\n\n* Catch up with recent changes in Hiccup.\n* Form helpers\n* Page helpers\n* Figure out if the runtime can be pulled in without an explicit require by the user\n* Explore potential performance improvements using Google's StringBuffer et al.\n\n","funding_links":[],"categories":["Awesome ClojureScript"],"sub_categories":["Document Object Model"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fteropa%2Fhiccups","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fteropa%2Fhiccups","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fteropa%2Fhiccups/lists"}