[cells-devel] family hierarchies
Andy Chambers
achambers.home at googlemail.com
Tue Mar 25 17:19:23 UTC 2008
Does it cause problems if a family is defined on a slot different from kids?
I ask because in a webified cells, you'd probably want to define the
model on a :page slot or something.
(defmodel web-app (family)
((page ...)
(request ...)
(:default-initargs
:page (c? (the-kids ....)))
I've made a few macros based on those in celtk that use cl-who to
populate an xhtml slot. The families
are building up quite nicely now. I am having one problem though.
The web pages are constructed using
macros like this...
(mk-page (:titile "some page")
(mk-div ()
(mk-text "hello world")))
I created a definehtml macro to make a defmodel and a corresponding
mk- macro for a few of the commonly
used html elements (I'll do the others as and when required). What
I'm not sure about is the mk-text for
simple strings. On the plus side, I can use a rule to escape special
characters like & et el. Another plus
is that we can put all text inside addressable span elements so if
only that bit of text updates, we can
send the appropriate bit of javascript down to the client that
pin-points the change we want.
Here's roughly how one of the mk- macros look at the moment.
(defmacro mk-div ((&rest inits) &body body)
`(make-instance
'div
, at inits
:fm-parent *parent*
:kids (c? (the-kids
,@(loop for kid in body
when (stringp kid)
collect (mk-text kid)
else
collect kid)))))) ;; not sure about the parens here, I edited
a bit in email
What I'd really like is to examine the type of each form in body to
see if its a string. If so, use the mk-text
macro to make that string into a family object. What you see above
does do that but it doesn't pick up the
*parent*, presumably because the macroexpansion of the mk-text bit
happens before *parent* has been
evaluated. Maybe the easiest thing would just be to use a really
short name for the mk-text macro and be
done with it.
Cheers,
Andy
More information about the cells-devel
mailing list