Skip to content

Instantly share code, notes, and snippets.

@nvbn
Created May 24, 2015 21:11
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 nvbn/2fb29382674e18eb9b76 to your computer and use it in GitHub Desktop.
Save nvbn/2fb29382674e18eb9b76 to your computer and use it in GitHub Desktop.
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