Problems with <r:random> tags

Hi,

I’m now having a problem with the <r:random> tag for inserting a
random image into a snippet.

I’ve looked at
http://dev.radiantcms.org/radiant/browser/trunk/radiant/app/models/page_context.rb
where I see:

<r:random>

<r:option>…</r:option>

<r:option>…</r:option>

<r:random>

Randomly renders one of the options specified by the ‘option’ tags.

define_tag ‘random’ do |tag|
tag.locals.random = []
tag.expand
options = tag.locals.random
option = options[rand(options.size)]
option.call if option
end
define_tag ‘random:option’ do |tag|
items = tag.locals.random
items << tag.block
end

It seems to me that the <r:option> tags used in the comments don’t
match the line

define_tag ‘random:option’ do |tag|

and so I tried <r:random:option> instead, but to no avail.

Here is the snippet:

This is a random image

TIA,

Dave C. wrote:

What output do you get from the above? Keep in mind that if the page is
being cached you won’t see a difference for at least 5 minutes.


John L.
http://wiseheartdesign.com

Hi John!

On 23/08/06, John W. Long [email protected] wrote:

.jpg" />

What output do you get from the above? Keep in mind that if the page is
being cached you won’t see a difference for at least 5 minutes.

The output is:

iMethod

On 23/08/06, John W. Long [email protected] wrote:

Dave C. wrote:

Ok, the extra new lines are the problem. Radiant tags observe whitespace
(that is, they won’t trim extra newlines off for you). Instead of the
what you had, try this:
<r:snip>
See the difference?

Yes - excellent - many thanks! :slight_smile:

Oh, and you don’t have to prefix the <r:option />
tags with “random:”.

Yes I see this is how the documentation in the comments is; since it
wasn’t working I tried looking at the ruby.

Dave C. wrote:

The output is:

This should output:

This is a random image

See the difference? Oh, and you don’t have to prefix the <r:option />
tags with “random:”.


John L.
http://wiseheartdesign.com