chickadee » waffle » load-widget

load-widget widget-name filenameprocedure

Loads a widget from the specified filename and makes it available as widget-name.

The files are similar to scheme source files and have markup and attribute sections thus:

(markup . `(*TOP*
  ,@(if user
    `(div (img (@ (class user-avatar) (src "/face.svg")))
          (span ,user)
          (a (@ (href "/logout")) "Log out"))
    `(a (@ (href "/login")) "Log in"))
))
(attributes . (
  (user #f)
))

The cdr of markup should evaluate to some sxml. You can use R5RS scheme and the variables listed in attributes to generate it. When the widget is called, if an attribute is specified then it is bound to that value otherwise it is bound to the default value specified in the attributes list.

If the above code was placed in the user-menu.widget.scm file you could load it thus:

(use waffle)
(load-widget 'user-menu "user-menu.widget.scm")