Last active
May 12, 2016 09:51
-
-
Save peeb/30a0fea0623be0e3ce2e3ca3040653ff to your computer and use it in GitHub Desktop.
Unified component rendering
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 akvo.components | |
(:require [rum.core :as rum] | |
#?(:cljs [goog.dom :as dom]))) | |
#?(:cljs (enable-console-print!)) | |
;;; Helpers | |
(defn now [] | |
(str "The date is " | |
#?(:clj (str (java.util.Date.) " according to Clojure!") | |
:cljs (str (js/Date.) " according to ClojureScript!")))) | |
;;; Components | |
(rum/defc header [] | |
[:header | |
[:h1 "Unified Components FTW"] | |
[:p (now)]]) | |
(rum/defc main [] | |
[:div#components | |
(header)]) | |
;;; Client-specific | |
#?(:cljs (rum/mount (main) (dom/getElement "main"))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment