           ;; Move through multiline attrs
           (when (eq (char-before) ?,)
             (save-excursion
-              (while (progn (end-of-line) (eq (char-before) ?,) (not (eobp)))
+              (while (progn (end-of-line) (and (eq (char-before) ?,) (not (eobp))))
                 (forward-line))
 
               (forward-line -1)

(defconst haml-font-lock-keywords
  `((,(haml-nested-regexp "\\(?:-#\\|/\\).*")  0 font-lock-comment-face)
    (,(haml-nested-regexp ":\\w+") 0 font-lock-string-face)
    (haml-highlight-interpolation  1 font-lock-variable-name-face prepend)
    (haml-highlight-ruby-tag       1 font-lock-preprocessor-face)
    (haml-highlight-ruby-script    1 font-lock-preprocessor-face)
    ("^ *\\(\t\\)"                 1 'haml-tab-face)
    ("^!!!.*"                      0 font-lock-constant-face)
    ("| *$"                        0 font-lock-string-face)))

(defconst haml-filter-re "^ *:\\w+")
(defconst haml-comment-re "^ *\\(?:-\\#\\|/\\)")

(defun haml-fontify-region-as-ruby (beg end)
  "Use Ruby's font-lock variables to fontify the region between BEG and END."
  (save-excursion
    (save-match-data
      (let ((font-lock-keywords ruby-font-lock-keywords)
            (font-lock-syntactic-keywords ruby-font-lock-syntactic-keywords)
            font-lock-keywords-only
            font-lock-extend-region-functions
            font-lock-keywords-case-fold-search)
        ;; font-lock-fontify-region apparently isn't inclusive,
        ;; so we have to move the beginning back one char
        (font-lock-fontify-region (- beg 1) end)))))

(defun haml-highlight-ruby-script (limit)
  "Highlight a Ruby script expression (-, =, or ~).


(eval-when-compile (require 'cl))
(require 'ruby-mode)

;; Additional (optional) libraries for fontification
(require 'css-mode nil nil)
(require 'textile-mode nil nil)
(require 'markdown-mode nil nil)
(require 'javascript-mode "javascript" nil)


;; User definable variables

