Skip to content

Instantly share code, notes, and snippets.

Created September 29, 2012 15:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/bd3b8fe4bc3bfe905268 to your computer and use it in GitHub Desktop.
Save anonymous/bd3b8fe4bc3bfe905268 to your computer and use it in GitHub Desktop.
(ns template.clj.core
(:use [clojure.string]))
(defn attr [a-map]
^{:doc "renders an attribute"}
(str (:name a-map) "='" (:value a-map) "'"))
(defn as-attr-list [ats]
^{:doc "renders a list of attributes"}
(clojure.string/join " " (map #(attr %) ats)))
(defn as-tag-list [tags]
^{:doc "renders a list of tags"}
(clojure.string/join "" (map str tags)))
(defn tag
^{:doc "renders a tag with or without attributes"}
([tag-name value attrs]
(str "<" tag-name " " (as-attr-list attrs) ">" value "</" tag-name ">"))
([tag-name value]
(str "<" tag-name ">" value "</" tag-name ">")))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment