Skip to content

Instantly share code, notes, and snippets.

@svetlyak40wt
Last active March 12, 2020 14:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save svetlyak40wt/2f2d4f3b6021bdf0ca880594076d4981 to your computer and use it in GitHub Desktop.
Save svetlyak40wt/2f2d4f3b6021bdf0ca880594076d4981 to your computer and use it in GitHub Desktop.
A spinneret breadcrumbs example.
(defvar *breadcrumbs*)
(defun render-breadcrumbs ()
(with-html
(:ul
(loop for (text . url) in *breadcrums*
do (:li (:a :href url
text))))))
(defun add-breadcrumb (text url)
(push (cons text url)
*breadcrumbs*))
(defun render-block-foo ()
(with-html
(:div :class "foo"
"Hello")
(add-breadcrumb "foo" "/foo")
(render-block-bar)))
(defun render-block-bar ()
(with-html
(:div :class "foo"
"Hello")
(add-breadcrumb "bar" "/foo/bar")))
(defun render-page ()
(let* ((*breadcrumbs* nil)
(main-content (with-html-string
(render-block-foo)))
(breadcrumbs (with-html-string
(render-breadcrumbs))))
(with-html
(:body (:header
(:raw breadcrumbs))
(:section
(:raw main-content))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment