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:

Example

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)))
#<REBLOCKS/WIDGETS/MOP:WIDGET-CLASS COMMON-LISP-USER::HELLO>

CL-USER> (defmethod reblocks/widget:render ((widget hello))
           (reblocks/html:with-html ()
             (:span ("Hello ~A" (get-name widget)))))
#<STANDARD-METHOD REBLOCKS/WIDGET:RENDER (HELLO) {1004E27BC3}>

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:

String widget

This is a simple type of widget which can be made out of any string.

Create it using reblocks/widgets/string-widget:make-string-widget function.