Skip to content

Instantly share code, notes, and snippets.

@peeb
Last active May 12, 2016 09:51
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 peeb/30a0fea0623be0e3ce2e3ca3040653ff to your computer and use it in GitHub Desktop.
Save peeb/30a0fea0623be0e3ce2e3ca3040653ff to your computer and use it in GitHub Desktop.
Unified component rendering
(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