This is pretty tiny for an extension, but it's got general use, so I figured I'd package it up. It's available here:
http://github.com/AndrewO/rerender_text/tree/master Anyway here's a selection from the README: This extension adds two methods to Radiant's Page model that allows you to easily define tags that can render their contents twice. The primary use for this is to add support for tags that occur before the necessary information to render them is available. Note that this extension doesn't actually contain any tags (aside from the ones in the spec), only a couple of methods that are handy for making your own. Example Say we want to add have a tag that creates a link to every header in a page. This would be simple if the tag occurred at the end of the page. However, most pages want this at the beginning. The solution is to do something like this: <r:capture_headers> <rr:table_of_contents/> <r:h1>Foo</r:h1> <r:h2>Bar</r:h2> </r:capture_headers> The <rr:toc/> tag is in a separate namespace than the others and thus won't be evaluated until afterward. In the <r:capture_headers/> tag we call rerender_text(tag.expand, :headers => headers) which sets up a new Radius context and parser to expand tags in the "rr" namespace. There's an example of a similar set of tags in spec/models/page_with_rerender_text_spec.rb which has an implementation of them. -Andrew _______________________________________________ Radiant mailing list Post: [email protected] Search: http://radiantcms.org/mailing-list/search/ Site: http://lists.radiantcms.org/mailman/listinfo/radiant
