I’m trying to define some macros to help with writing templates. Basically,
I want to look at a document’s metas and then fill in a default if there is
a missing meta key.
So in pollen.rkt I have the following:
(define-syntax-rule (with-default call default)
(let ([tmp call])
(if tmp tmp default)))
(define (get-description metas)
(with-default (select-from-metas 'description metas)
“My Wesbsite description"))
(define-syntax-rule (desc) (get-description (syntax->datum #'metas)))
And inside my template.html.p I have
<meta name="description" content="◊(desc)">
I used the syntax->datum part because I know that metas won’t be available
in pollen.rkt, so I need to splice it in when the macro is expanded in the
template. However, I get the following error:
raco pollen render
rendering generated pagetree for directory /Users/basus/src/basus/
rendering: /error.html.pm as /error.html
rendering: /template.html.p as /template.html
select-from-metas: no source found for 'metas' in directory
/Users/basus/src/basus/
context...:
get-metas
/Users/basus/src/pollen/pollen/core.rkt:54:0: select-from-metas
/Applications/Racket
v6.4/collects/racket/contract/private/arrow-val-first.rkt:269:25
/Users/basus/src/basus/pollen.rkt:67:0: get-description
/Users/basus/src/pollen/pollen/render.rkt:209:0:
render-markup-or-markdown-source33
/Users/basus/src/pollen/pollen/render.rkt:132:0: render26
/Users/basus/src/pollen/pollen/private/cache-utils.rkt:97:2:
fetch-dest-file
/Applications/Racket v6.4/collects/file/cache.rkt:63:2:
fetch-and-continue
/Applications/Racket
v6.4/collects/racket/contract/private/arrow-val-first.rkt:335:3
/Users/basus/src/pollen/pollen/private/cache-utils.rkt:88:0: cache-ref!14
/Applications/Racket
v6.4/collects/racket/private/more-scheme.rkt:373:13: hash-ref!
render-to-file-if-needed
/Users/basus/src/pollen/pollen/render.rkt:73:0:
render-from-source-or-output-path
loop
/Users/basus/src/pollen/pollen/private/command.rkt:100:8: render-one-dir
(submod /Users/basus/src/pollen/pollen/private/command.rkt raco):
[running body]
…
Admittedly, I don’t know much about the Racket macro expansion (I read the
relevant part of Beautiful Racket) and I’m not entirely sure how template
expansion works in Pollen, so it’s possible I’m missing something basic?
Thanks,
Basu
--
You received this message because you are subscribed to the Google Groups
"Pollen" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.