Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;;;; Short code example to demonstrate basic Radiance development.
- ;; Include radiance package to get access to all the necessary things as well as lQuery for page construction.
- (use-package '(:radiance :lquery))
- ;; Start Radiance
- (manage #'start)
- ;; Define a new module
- (defmodule my-module ()
- "My first radiance module."
- (:name "My Module" :version "0.0.1" :author "The Future"))
- ;; Create a new method on the module that'll print a page using lQuery.
- (defmethod my-page ((module my-module))
- ($ (initialize #p"/path/to/template.html"))
- ($ "h1" (html "Hi!"))
- ($ "p" (html "Welcome to... <b>THE FUTURE!</b>"))
- (first ($ (serialize))))
- ;; Define a hook for the method and register it with the dispatcher.
- (defhook 'my-page (get-module 'my-module) #'my-page)
- (register (implementation 'dispatcher) 'my-page)
- ;; You can now call http://localhost:4545/ in your browser and you should see your page!
- ;; Of course, assuming your radiance config is set up to listen on port 4545
- ;; and the template file used in my-page actually exists.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement