Learn Ring - 8. Hiccup
Code
project.clj
(defproject little_ring_things "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url "http://example.com/FIXME"
:min-lein-version "2.0.0"
:dependencies [[org.clojure/clojure "1.12.4"]
[compojure "1.6.1"]
[ring/ring-defaults "0.3.2"]
[hiccup "2.0.0"]]
:plugins [[lein-ring "0.12.5"]]
:ring {:handler little-ring-things.handler/app}
:profiles
{:dev {:dependencies [[javax.servlet/servlet-api "2.5"]
[ring/ring-mock "0.3.2"]]}})
template.clj
(ns little-ring-things.template
(:require [hiccup2.core :as h]))
(defn template [title body]
(str
"<!DOCTYPE html>\n"
(h/html
[:html
[:head
[:meta {:charset "UTF-8"}]
[:title title]]
[:body
body]])))
Notes