          width (:width attrs)
          height (:height attrs)
          s (hiccup.core/html (conj body t))]
+     (bootstrap)
      (Platform/runLater (fn [] (.setPrefHeight @webview height)))
      (Platform/runLater (fn [] (.setPrefWidth @webview width)))
      (render-string s)
-     (wait-for-worker)
      (Platform/runLater (fn [] (.sizeToScene @stage)))
      (Platform/runLater (fn [] (.show @stage)))
      s)))

(defn render
  ([filename t]
   (export-to-file filename t)
   (render t))
  ([t]
   (let [body [:body (style
                       :margin "0 !important"

          (= Worker$State/CANCELLED state) state
          :else (do (Thread/sleep 10) (recur)))))

(defn bootstrap []
  (if @engine
    nil
    (do
      (launch)
      (.await latch))))

(defn render-string [s]
  (Platform/runLater (fn [] (.loadContent @engine s "text/html")))
  (wait-for-worker))

(defn translate [x y]
  (str "translate(" x "," y ")"))
