[Seaside] S-Expr conditionals
Avi Bryant
avi@beta4.com
Sat, 1 Jun 2002 14:34:56 -0700 (PDT)
On Sat, 1 Jun 2002, Jim Benson wrote:
> html
> ^ #(
> b ' ' '[date.monthName]' ' ' '[date.year.printString]'
Just so ya know, you don't have to separate out the various strings like
that - this could just be
^ #(
b ' [date.monthName] [date.year.printString]'
> As an example, what I would like to do in the days of the month area [ tr
> repeat: @week/weeks ] bgcolor: is to say something like
>
> [ Equivalent Squeak saying ]
>
> backgroundColor :=
> ( aDay = Date today ) ifTrue: [ 'ff0000' ] ifFalse: [
> 'ffff99' ].
> self bgcolor: backgroundColor.
What you need is to bind to the bgcolor of that cell. In 0.93, that
means something like this:
MyCalendarComponent>>addBindingsTo: template
(template elementNamed: 'aDay/week')
set: #bgcolor toPath: 'dayBackground'.
Then you need to write the #dayBackground method to return the correct
color. This will need to know the value of 'aDay', which is a
template-local variable, and so is stored in 'locals'. So you want
something like this:
dayBackground
^ (locals at: #aDay) = Date today
ifTrue: ['ff0000']
ifFalse: ['ffff99']
That work?