Closed aartaka closed 1 year ago
What's happening is that with-html
is walking the form before deftag
gets expanded, so when deftag
receives its arguments they've already been wrapped in with-tag
forms;
(macroexpand-1
'(with-html
(:ul*
"Item 1"
"Item 2"
(:b "Bold item 3")
(:li "Proper <li> item 4")
"Item 5"))'
=>
(let ((*html* (spinneret::ensure-html-stream *html*)))
(progn
(:ul*
"Item 1"
"Item 2"
(spinneret::with-tag (:b)
"Bold item 3")
(spinneret::with-tag (:li)
"Proper <li> item 4")
"Item 5")))
I think the right thing to do here is to have the walker detect that :ul*
is defined as a deftag and not descend into it. I've pushed a branch that does this, dont-descend-deftag
. It doesn't break any tests but I want to do some more experimentation before I merge it to master.
Thanks for working on it, you've made my code and website much simpler :black_heart:
I have this smart macro,
:ul*
, which makes strings (or any forms) inside its body to be wrapped into their own<li>
s. But then, if one wants to force a<li>
,:ul*
should just skip the wrapping and insert it literally. Here's how I've implemented it:Which seems absolutely valid. But when I run
it prints
So, it seems, the literal
:li
is somehow printed before the tag macro is expanded. Which seems wrong.Is it possible to force
deftag
ged macro expansion to happen before the tag printing?