[cl-who-devel] Interpolate lisp code inside the tag body
Sebastian Tennant
sebyte at smolny.plus.com
Thu Jul 28 08:06:06 UTC 2011
Quoth Matus Kmit <simply.nitaai at gmail.com>:
> How does one properly embed and evaluate lisp code inside the tag body?
You can 'embed' the *value* of an attribute, but not attributes themselves.
In practice this is not a serious limitation.
> (:p (fn)) does not work.
No, but this does:
(flet ((fn () "value"))
(with-html-output-to-string (s)
(:p :attribute (fn))))
=> "<p attribute='value'></p>"
Note, that to do something similar in the text node of an element, you should
use one of the exported symbols; esc, fmt or str.
http://weitz.de/cl-who/#esc
For example:
(flet ((fn () "Attributes and their values"))
(with-html-output-to-string (s)
(:h1 (str (fn)))))
=> "<h1>Attributes and their values</h1>"
Hope this helps,
Sebastian
--
Emacs' AlsaPlayer - Music Without Jolts
Lightweight, full-featured and mindful of your idyllic happiness.
http://home.gna.org/eap
More information about the Cl-who-devel
mailing list