       (while (not (eq indent (current-column)))
         (forward-char (- indent (current-column))))
       ;; if the line is empty, leave it empty
-      (if (eolp) (indent-line-to 0))
-      )))
+      (if (eolp)
+          (progn
+            (indent-line-to 0)
+            (setq indent 0))))
+    indent))
 
 (defun zotonic-tpl-indent-buffer ()
   "Indent entire buffer."

    ))

;;;
;;; Define zotonic major mode
;;;


        ))))

(defun zotonic-tpl-indent-line ()
  "Indent zotonic template code. Returns the indentation used."
  (interactive)
  (let ((indent
         (save-excursion
