Back

render-html (clj)

(source)

protocol

(render-html this)
Turn a Clojure data type into a string of HTML.

Examples

clojurewerkz/money
(ns clojurewerkz.money.hiccup
  "Provides Hiccup integration: HTML rendering of monetary amounts"
  (:require [clojurewerkz.money.format :as fmt]
            [hiccup.compiler           :as hup])
  (:import [org.joda.money Money CurrencyUnit]))


(extend-protocol hup/HtmlRenderer
  Money
  (render-html [^Money money]
    (fmt/format money))

  CurrencyUnit
  (render-html [^CurrencyUnit cu]
    (.getCode cu)))
emil0r/reverie
(ns reverie.render
  "Render protocol and Renderer implementation"
  (:require [clojure.core.match :refer [match]]
            [hiccup.compiler]
            [reverie.system :as sys]
            [reverie.util :as util]
            [taoensso.timbre :as log]))

(def get-render-fn nil)
(defmulti get-render-fn identity)
(defmethod get-render-fn :hiccup [_]
  ;; render as hiccup
  hiccup.compiler/render-html)
(defmethod get-render-fn :default [_]
  ;; if nothing is defined, we just return what we get
  identity)