[Radiant] Container tag with default values for nested tags
Sean Cribbs
seancribbs at gmail.com
Sun Jun 1 09:51:35 CDT 2008
Casper,
Call parse, passing the text you want to parse:
hash[:normal] ||= parse('<li><r:link /></li>')
Sean
Casper Fabricius wrote:
> I'm developing a tag inspired by the way <r:navigation /> works; by
> using nested tags to let the user specify how he wants to render a
> given collection.
>
> The user could write:
> <r:collection_tag>
> <r:normal><b><r:link></b></r:normal>
> </r:collection_tag>
>
> - and the tag uses this nested tag by doing:
> hash = tag.locals.collection_tag = {}
> tag.expand
>
> - and then later:
> hash[:normal].call
>
> - to render the contents of the nested tag.
>
> However, I want the user to also be able to write just:
> <r:collection_tag />
>
> - and the tag will populate hash[:normal] with a default value of,
> say, <r:link />.
>
> However, I don't know how to create a default value for a nested tag,
> least not when it contains other Radius tags that need to be parsed in
> the context of each iteration of the collection.
>
> I have tried assigning default values with code such as:
> hash[:normal] ||= '<li><r:link /></li>'
>
> - or:
> hash[:normal] ||= Proc.new {'<li><r:link /></li>'}
>
> - but the first is just a string, and does not respond to the #call
> method, and the second is just a proc, and do not in fact render
> <r:link /> in the context, it just returns the string unparsed.
>
> I know of several examples on using default values for tag attributes,
> but not for nested tags. Any hints, ideas, examples?
>
> Cheers,
> Casper Fabricius
> http://casperfabricius.com
>
> _______________________________________________
> Radiant mailing list
> Post: Radiant at radiantcms.org
> Search: http://radiantcms.org/mailing-list/search/
> Site: http://lists.radiantcms.org/mailman/listinfo/radiant
>
More information about the Radiant
mailing list