Skip to content

Instantly share code, notes, and snippets.

@nvbn nvbn/core.clj
Created May 24, 2015

Embed
What would you like to do?
svg-image-example
(ns svg-image-example.core
(:require [om.core :as om :include-macros true]
[om.dom :as dom]))
(defn image
[{:keys [href x y width height]} _]
(reify
om/IRender
(render [_]
(let [html (str "<image x='" x "' y='" y "'"
"width='" width "' height='" height "'"
"xlink:href='" href "'/>")]
(dom/g #js {:dangerouslySetInnerHTML #js {:__html html}})))))
(defn scene
[_ _]
(reify
om/IRender
(render [_]
(dom/svg #js {:width 150
:height 150}
(om/build image {:href "http://clojure.org/space/showimage/clojure-icon.gif"
:x 5
:y 5
:width 100
:height 100})))))
(om/root scene {} {:target (.getElementById js/document "main")})
<html>
<body>
<div id="main"></div>
<script src="result.js"></script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.