Skip to content

Instantly share code, notes, and snippets.

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

What would you like to do?
(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]} _]
(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
[_ _]
(render [_]
(dom/svg #js {:width 150
:height 150}
(om/build image {:href ""
:x 5
:y 5
:width 100
:height 100})))))
(om/root scene {} {:target (.getElementById js/document "main")})
<div id="main"></div>
<script src="result.js"></script>
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.