[Radiant] Yeilding Snippets
Sean Cribbs
seancribbs at gmail.com
Thu Feb 14 08:21:18 CST 2008
Something like this:
(in your snippet tag)
tag.locals.yield = tag.expand
tag 'yield' do |tag|
tag.locals.yield
end
Andrew Neil wrote:
> Sean, thanks for your reply. I thought there would be more to it than
> that, but you made it sound easy, so I gave it a go. Here is the ticket:
>
> http://dev.radiantcms.org/radiant/ticket/611
> http://dev.radiantcms.org/radiant/attachment/ticket/611/enable_snippets_as_double_tag_with_yield.diff
>
>
>> You would need to capture the contents of the <r:snippet /> tag before
>> rendering the snippet, either using tag.block or tag.expand and saving
>> it in a local. Then your <r:yield /> tag would emit that local.
>>
>
> I wasn't sure how to save tag.expand in a local so that it was
> accessible from <r:yield/>, so I've cheated a little:
>
> snippet.content.gsub!(%r{<r\:yield\s?/?>}, tag.expand)
>
> and making <r:yield/> output nothing. It's not exactly idiomatic, but
> it passes the tests!
>
> Cheers,
>
> Drew
> _______________________________________________
> Radiant mailing list
> Post: Radiant at lists.radiantcms.org
> Search: http://radiantcms.org/mailing-list/search/
> Site: http://lists.radiantcms.org/mailman/listinfo/radiant
>
>
More information about the Radiant
mailing list