GithubHelp home page GithubHelp logo

plumpmath / hiccup Goto Github PK

View Code? Open in Web Editor NEW

This project forked from weavejester/hiccup

0.0 0.0 0.0 418 KB

Fast library for rendering HTML in Clojure

Home Page: http://weavejester.github.com/hiccup

License: Eclipse Public License 1.0

Clojure 100.00%

hiccup's Introduction

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.

hiccup's People

Contributors

abedra avatar algernon avatar arohner avatar asmala avatar bronsa avatar budu avatar christophermaier avatar ericlavigne avatar fracek avatar geoffsalmon avatar gerrit-hntschl avatar iku000888 avatar indy avatar jcrossley3 avatar jiriknesl avatar joodie avatar kfahy avatar lynaghk avatar masaedw avatar paraseba avatar simon-nicholls avatar stesla avatar weavejester avatar wiseman avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.