diff --git a/src/flute.lisp b/src/flute.lisp index 5db3cf0..5cb2fe7 100644 --- a/src/flute.lisp +++ b/src/flute.lisp @@ -133,15 +133,17 @@ When given :ASCII and :ATTR, it's possible to insert html text as a children, e. `(defun ,name (&rest ,g!attrs-and-children) (multiple-value-bind (,g!attrs ,g!children) (split-attrs-and-children ,g!attrs-and-children) - (let ,(mapcar (lambda (arg) - (list arg `(cdr (assoc (make-keyword ',arg) (attrs-alist ,g!attrs))))) - args) - (make-user-element :tag (string-downcase ',name) :attrs ,g!attrs - :children ,g!children - :expander - (lambda (tag attrs children) - (declare (ignorable tag attrs children)) - (progn ,@body))))))) + (let ((,g!element + (make-user-element :tag (string-downcase ',name) :attrs ,g!attrs + :children ,g!children))) + (setf (user-element-expander ,g!element) + (lambda (tag attrs children) + (declare (ignorable tag attrs children)) + (let ,(mapcar (lambda (arg) + (list arg `(attr attrs (make-keyword ',arg)))) + args) + (progn ,@body)))) + ,g!element)))) (defvar *expand-user-element* t) diff --git a/t/flute.lisp b/t/flute.lisp index 1e5bb35..88d5f17 100644 --- a/t/flute.lisp +++ b/t/flute.lisp @@ -234,7 +234,8 @@ (is (string= "woo" (second (element-children dog4)))) (setf (attr dog4 :size) 16) - (is (= 16 (attr dog4 :size))) - (is (string= "big-dog" (attr (user-element-expand-to dog4) :class))))) + (is (string= "big-dog" (attr (user-element-expand-to dog4) :class))) + (setf (element-children dog4) (list dog1 dog2 dog3)) + (is (equal (list dog1 dog2 dog3 "dog") (element-children (user-element-expand-to dog4)))))) (run-all-tests)