   @autorun =>
     if @subsReady.get()
       Meteor.defer =>
-        # Wait a tick for template to re-render
+# Wait a tick for template to re-render
         post = Blog.Post.first(@id.get())
         if post?
-          # Load post body initially, if any
+# Load post body initially, if any
           @$('.editable').html post.body
           @$('.html-editor').html post.body
 

    $editable.html($html.val()?.trim())
    $html.height($editable.height())

  # Autosave
  'input .editable, keydown .editable, keydown .html-editor': _.debounce (e, tpl) ->
    save tpl, (id, err) ->
      if err
        return toastr.error err.message

      if id
        # If new blog post, subscribe to the new post and update URL
        tpl.id.set id
        path = Blog.Router.pathFor 'blogAdminEdit', id: id
        Blog.Router.replaceState path



Template.blogAdminEdit.events
# Toggle between VISUAL/HTML modes
  'click [data-action=toggle-visual]': (e, tpl) ->
    if tpl.$('.editable').is(':visible')
      return
