> I must be missing it, I don't see an expand method anywhere other than here:
> http://radius.rubyforge.org/classes/Radius/TagBinding.html#M000011
>   
Ok, looks like I'll have to explain in more detail.  For reference, I'm 
looking at 
http://dev.radiantcms.org/radiant/browser/branches/mental/radiant/app/models/standard_tags.rb#L461
 
.

The second line inside the tag definition, line 463, calls 
'tag.expand'.  This causes any tags nested inside (in the page, mind 
you) to be rendered/evaluated.  The tags usually nested inside 
<r:navigation> are listed starting at line 489.  Here's their definitions:

  [:normal, :here, :selected, :between].each do |symbol|
    tag "navigation:#{symbol}" do |tag|
      hash = tag.locals.navigation
      hash[symbol] = tag.block
    end
  end

This generates tag definitions for everything in that array in the first 
line of the snippet.  So, for each one, we grab the 
'tag.locals.navigation' that was assigned by the *parent tag* 
(originally blank), and assign the hash key associated with this tag to 
the tag block.  So essentially, you're passing a block/closure/proc back 
to the parent tag that can be evaluated contextually (multiple times).

So here's an overview, again:

1) <r:navigation> somewhere in your page invokes the tag definition.
2) We assign a blank Hash to tag.locals.navigation (and also, 
incidentally, to a local var called 'hash' -- all variables are just 
references/by-reference in Ruby, so they're really the same object)
3) We evaluate the contained block inside <r:navigation> by calling 
tag.expand
3.5) Each contained tag of 'normal', 'here', 'selected', 'between' 
assigns its contained block to a key in tag.locals.navigation for future 
evaluation.
4) <r:navigation> evaluation continues -- parsing the urls/titles, 
evaluating various of the passed blocks on each one, depending on URL, 
then joining them together for output.

Let me know if I can clear anything else up.

Cheers,

Sean Cribbs
_______________________________________________
Radiant mailing list
Post:   [email protected]
Search: http://radiantcms.org/mailing-list/search/
Site:   http://lists.radiantcms.org/mailman/listinfo/radiant

Reply via email to