Widgets ΒΆ

Widget objects should subclasses of reblocks/widget:widget class also, minimally you have to define a method for the reblocks/widget:render generic-function. This function should return use reblocks/html:with-html macro to render the widget.

Other parts of API around widgets are:


To define a widget, use reblocks/widget:defwidget macro. It creates a class with a proper meta-class. Old Weblocks version used this metaclass to discover changes slots, and probably this feature will be returned back some day.

CL-USER> (reblocks/widget:defwidget hello ()
           ((name :initarg :name
                  :reader get-name)))

CL-USER> (defmethod reblocks/widget:render ((widget hello))
             (:span ("Hello ~A" (get-name widget)))))

Then call this, to run a webserver and preview your widget in the browser:

CL-USER> (reblocks/preview:preview
          (make-instance 'hello
                         :name "Bob"))

A result will look like this: