4

I am trying to generate the following HTML fragment using clojure.browser.dom, however it looks like it works different than hiccup,

<div data-role="controlgroup">
<a href="index.html" data-role="button">Yes</a>
<a href="index.html" data-role="button">No</a>
<a href="index.html" data-role="button">Maybe</a>
</div>

What is the correct notation for generating HTML element? Using,

[:div {:data-role "controlgroup"} ...]

does not generate,

<div data-role="controlgroup">

3 Answers 3

5

Also have a look at dommy which is essentially an optimised version of crate (the cljs version of hiccup) that murtaza52 suggested.

Sign up to request clarification or add additional context in comments.

Comments

4

Have a look at crate - https://github.com/ibdknox/crate - it is a port of hiccup to cljs.

Also look at enfocus which is an implementation of enlive - https://github.com/cgrand/enlive

Comments

1

Have a look a flurfunk's web front-end at https://github.com/flurfunk/flurfunk-web. They appear to have rolled their own ClojureScript library to generate html and the interface looks similar in nature to hiccup.

Here's a snippet from https://github.com/flurfunk/flurfunk-web/blob/master/src/cljs/flurfunk/web/core.cljs:

(ns flurfunk.web.core
  (:require [flurfunk.web.dom-helpers :as dom]))
(defn- create-dom []
  (dom/build [:div#content
               [:h1
                 [:a {:href "http://flurfunk.github.com"} title]]
               [:div#messages
                 [:div#message-input
                   [:div
                     [:label "Your name:"]
                     [:input#author-name-input {:type "text"}]]
                   [:textarea#message-textarea]
                   [:button#send-button "Send message"]
                   [:div#waiting-indication]]
                 [:div#hidden-channels
                   [:label "Hidden channels:"]
                   [:ul#hidden-channel-list]]
                 [:div#message-list]]
               [:button#load-more-button "Load more messages"]]))

1 Comment

It is the same. They copy/pasted dom helpers from twitterbuzz sample application.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.