How to compile a function that uses a cl-annot annotation ?
Use case:
Lucerne uses it to define routes:
@route app "/profile/:username"
(defview profile (username)
(let* ((user (utweet.models:find-user username))
;; The user's timeline
(user-tweets (utweet.models:user-tweets user))
;; Is the user viewing his own profile?
(is-self (string= (lucerne-auth:get-userid)
username)))
(render-template (+profile+)
:user user
:tweets (display-tweets user-tweets)
:is-self is-self)))
I made it work with one view. But writing a second one and compiling it with C-c-c
would not work. I installed slime-annot.el
for emacs, but I only get
The variable @ROUTE is unbound.
[Condition of type UNBOUND-VARIABLE]
I did wrote (annot:enable-annot-syntax)
at the beginning.
So this a blocking point :/ How can we define new stuff using cl-annot ?
Thanks
ps: related issue
edit: more about the file structure: I created a project with Lucerne's project creator, this is the beginning of my main file:
(in-package :cl-user)
(defpackage lucerne-books
(:use :cl
:lucerne
:cl-arrows
:str)
(:export :app)
(:documentation "Main lucerne-books code."))
(in-package :lucerne-books)
(annot:enable-annot-syntax)
;;; App
(defapp app
:middlewares ((clack.middleware.static:<clack-middleware-static>
:root (asdf:system-relative-pathname :lucerne-books #p"assets/")
:path "/static/")))
;;; Templates
(djula:add-template-directory
(asdf:system-relative-pathname :lucerne-books #p"templates/"))
(defparameter +index+ (djula:compile-template* "index.html"))
;;; Views
@route app "/" ;; first created: it works
(defview index ()
(render-template (+index+)
:foo "you"))
@route app "/rst" ;; this view won't work, not accessible
(defview index ()
(render-template (+index+)
:foo "rst"))
@route app "/following/:username" ;; this one neither
(defview user-following (username)
(let ((user username))
(render-template (+index+)
:foo user)))
I found a different notation on a Caveman project. It doesn't appear on cl-annot's doc, but it works:
(syntax:use-syntax :annot)
I can now C-c C-c
new routes.