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.
This commit is contained in:
Gered 2016-06-13 12:18:14 -04:00
parent 8d65b78703
commit 4f08c1c2a1
2 changed files with 25 additions and 0 deletions

View file

@ -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"]]

24
src/webtools/page.clj Normal file
View file

@ -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)
(-> ["<!--[if lt IE 10]>" "<html class=\"old-ie no-websockets\">" "<![endif]-->"
"<!--[if gte IE 10]>" "<html>" "<![endif]-->"
"<!--[if !IE]> -->" "<html>" "<!-- <![endif]-->"]
(concat contents)
(concat ["</html>"]))))
(defn js-env-settings
[context-url dev?]
(javascript-tag
(string/join "\n"
[(str "var __context = '" context-url "';")
(str "var __isDev = " (boolean dev?) ";")])))