All Projects → weavejester → Hiccup

weavejester / Hiccup

Licence: epl-1.0
Fast library for rendering HTML in Clojure

Programming Languages

clojure
4091 projects

Projects that are alternatives of or similar to Hiccup

Reagent
The idea and some of the code for making components atom-like comes from pump. The reactive-atom idea (and some code) comes from reflex.
Stars: ✭ 4,344 (+85.88%)
Mutual labels:  hiccup
hiccup-d3
D3-Charts written in Clojure
Stars: ✭ 74 (-96.83%)
Mutual labels:  hiccup
pour
Declarative, composable and extensible tree querying and transformation based on EQL.
Stars: ✭ 36 (-98.46%)
Mutual labels:  hiccup
hn-clojure
Hacker News in Clojure.
Stars: ✭ 31 (-98.67%)
Mutual labels:  hiccup
tailwind-hiccup
tailwindcss + hiccup = 👍👍
Stars: ✭ 34 (-98.55%)
Mutual labels:  hiccup
hx
A simple, easy to use library for React development in ClojureScript.
Stars: ✭ 244 (-89.56%)
Mutual labels:  hiccup

Hiccup

Build Status

Hiccup is a library for representing HTML in Clojure. It uses vectors to represent elements, and maps to represent an element's attributes.

Install

Add the following dependency to your project.clj file:

[hiccup "1.0.5"]

Documentation

Syntax

Here is a basic example of Hiccup syntax:

user=> (use 'hiccup.core)
nil
user=> (html [:span {:class "foo"} "bar"])
"<span class=\"foo\">bar</span>"

The first element of the vector is used as the element name. The second attribute can optionally be a map, in which case it is used to supply the element's attributes. Every other element is considered part of the tag's body.

Hiccup is intelligent enough to render different HTML elements in different ways, in order to accommodate browser quirks:

user=> (html [:script])
"<script></script>"
user=> (html [:p])
"<p />"

And provides a CSS-like shortcut for denoting id and class attributes:

user=> (html [:div#foo.bar.baz "bang"])
"<div id=\"foo\" class=\"bar baz\">bang</div>"

If the body of the element is a seq, its contents will be expanded out into the element body. This makes working with forms like map and for more convenient:

user=> (html [:ul
               (for [x (range 1 4)]
                 [:li x])])
"<ul><li>1</li><li>2</li><li>3</li></ul>"

License

Copyright © 2016 James Reeves

Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].