-
-
Save anonymous/bd3b8fe4bc3bfe905268 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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