[Radiant] Behavior vs. Context
Jay Levitt
lists-radiant at shopwatch.org
Fri Jul 28 09:27:48 CDT 2006
Sean Cribbs wrote:
> I've been doing this via a plugin, as follows:
>
> class Behavior::Base
> define_tags do
> tag "slicktabs" do |tag|
> slicktab = SlickTabs.new(tag)
> slicktab.output
> end
> ...other tags...
> end
> end
>
> class SlickTabs
> ...
> end
>
>
> So essentially, Behavior::Base is available whether there's a behavior
> assigned or not? Or am I misunderstanding?
I just wrote a whole screed about reopening classes in Ruby, then
realized you were asking if Behavior::Base is always available -to the
page-. Oops.
From experience, yes - you don't need a behavior defined to use the
tags you call from Behavior::Base. I'm not sure entirely why; John can
shed some light, I'm sure.
I think it's because Behavior::Base acts as kind of an abstract base
class - it sets up a bunch of helpers for defining tags, but (normally)
doesn't call any of them itself. Any behaviors you write would descend
from it and call them. And Page seems to delegate to Behavior no matter
what, so if no other behavior is defined, you're still getting
Behavior::Base, which normally does nothing. Now that you've reopened
it, you're defining some tags as well - you've modified the "nil" behavior.
I'm very muddy on this advanced_delegation stuff, so my explanation of
WHY it works may be totally wrong. But it works. Just like a cargo cult.
Jay
> ------------------------------------------------------------------------
>
> _______________________________________________
> Radiant mailing list
> Radiant at lists.radiantcms.org
> http://lists.radiantcms.org/mailman/listinfo/radiant
More information about the Radiant
mailing list