Dependencies
When Reblocks renders page, it collects CSS
and JS
dependencies from all widgets
by calling generic-function reblocks/dependencies:get-dependencies
. Also, this function
is called on the current app to get such common dependencies as jQuery and CSS
framework.
If you are defining your own method for reblocks/dependencies:get-dependencies
generic-function,
make sure it returns a list of reblocks/dependencies:dependency
objects.
Typically, you already have JS
or CSS
file somewhere near your ASDF
system. In this case,
you can use reblocks/dependencies:make-dependency
function like this:
(defmethod reblocks/dependencies:get-dependencies ((app my-app))
(list* (reblocks/dependencies:make-dependency "js/my-app.js"
:system :some-asdf-system)
(call-next-method)))
Other way to specify a dependency is to use Parenscript or LASS
to define JS
or CSS
right inside
the method. Here we define CSS
code for the widget:
(defmethod reblocks/dependencies:get-dependencies ((widget my-custom-widget))
(list*
(reblocks-lass:make-dependency
`(.my-custom-widget
:border 2px solid red
:padding 1em))
(call-next-method)))
Pay attention, this code uses REBLOCKS-LASS:MAKE-DEPENDENCY
function which is available from
the separate asdf system REBLOCKS-LASS
.