                (rest substitutions))
         slug))))
 
-(defn sync-slug-with-title []
+(defn sync-slug-with-title [feed]
   (when-not (.checked (dom/getElement "custom-slug"))
     (let [title (.value (dom/getElement "title"))
           slug-el (dom/getElement "slug")]
-      (ui/set-form-value slug-el (create-slug title))
+      (ui/set-form-value slug-el (create-slug feed title))
       (document/get-doc (.value slug-el) handle-duplicate-slug-callback))))
 
-(defn toggle-custom-slug []
+(defn toggle-custom-slug [feed]
   (let [slug-el (dom/getElement "slug")]
     (if (.checked (dom/getElement "custom-slug"))
       (ui/enable-element slug-el)

  (soy/renderElement (dom/getElement "main-page") tpl/document-not-found))

(defn render-editor
  ([tpl-map] (render-editor tpl-map nil))
  ([tpl-map content]
     (if (= "new" (:status tpl-map))
       (do
         (render-editor-template tpl-map)
         (events/listen (dom/getElement "title")
                        event-type/INPUT
                        sync-slug-with-title)
         (events/listen (dom/getElement "slug")
                        event-type/INPUT
                        validate-slug)
         (events/listen (dom/getElement "custom-slug")
                        event-type/CHANGE
                        toggle-custom-slug)
         (events/listen (dom/getElement "save-document")
                        "click"
                        save-new-document-click-callback))

        (ui/remove-error (dom/getElement "status-message")
                           slug-el
                           (dom/getElement "slug-label"))
        (sync-slug-with-title feed)))))

(defn validate-slug []
  (if (.checked (dom/getElement "custom-slug"))
