From 4f08c1c2a1601bccfdd3f43b185f936cef45564c Mon Sep 17 00:00:00 2001 From: gered Date: Mon, 13 Jun 2016 12:18:14 -0400 Subject: [PATCH] add hiccup page html helper basically same idea as hiccup's existing html5 function, but includes some conditional html designed to work in conjunction with some of the clojurescript utility functions to detect whether an old IE version is in use, or lack of websockets support, etc. --- project.clj | 1 + src/webtools/page.clj | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 src/webtools/page.clj diff --git a/project.clj b/project.clj index 9a0b319..7229c49 100644 --- a/project.clj +++ b/project.clj @@ -6,6 +6,7 @@ :dependencies [[cheshire "5.5.0"] [prismatic/schema "1.0.4"] + [hiccup "1.0.5"] [cljs-ajax "0.5.5"] [secretary "1.2.3"]] diff --git a/src/webtools/page.clj b/src/webtools/page.clj new file mode 100644 index 0000000..94cf6cf --- /dev/null +++ b/src/webtools/page.clj @@ -0,0 +1,24 @@ +(ns webtools.page + (:require + [clojure.string :as string] + [hiccup.core :refer [html]] + [hiccup.page :refer [doctype]] + [hiccup.element :refer [javascript-tag]])) + +(defn html5 + [& contents] + (html + {:mode :html} + (doctype :html5) + (-> ["" + "" + "" "" ""] + (concat contents) + (concat [""])))) + +(defn js-env-settings + [context-url dev?] + (javascript-tag + (string/join "\n" + [(str "var __context = '" context-url "';") + (str "var __isDev = " (boolean dev?) ";")])))