Custom Radiant Tags

tag ‘kids:kid_sport_list’ do |tag|
kid = tag.locals.kid
kid.sports.each do |sport|
%{#{sport.name})
end
end

For some reason this outputs a “#” for each sport in kid.sports instead
of the name… Would anyone know why?

On Feb 3, 2009, at 11:12 AM, Little K. wrote:

tag ‘kids:kid_sport_list’ do |tag|
kid = tag.locals.kid
kid.sports.each do |sport|
%{#{sport.name})
end
end

For some reason this outputs a “#” for each sport in kid.sports
instead
of the name… Would anyone know why?

looks like you have a ) where you should have a }

Jim G. wrote:

On Feb 3, 2009, at 11:12 AM, Little K. wrote:

tag ‘kids:kid_sport_list’ do |tag|
kid = tag.locals.kid
kid.sports.each do |sport|
%{#{sport.name})
end
end

For some reason this outputs a “#” for each sport in kid.sports
instead
of the name… Would anyone know why?

looks like you have a ) where you should have a }

That’s just a result of me typing wrong on this forum, not causing the
problem. Its correct in my code.

Also, each just iterates over the collection and then returns the
original collection. You’ll want to use map/collect or inject instead.

tag ‘kids:kid_sport_list’ do |tag|
kid = tag.locals.kid
kid.sports.map {|s| s.name.to_s }.join(", ")
end

Sean

Thank you, very helpful!

On Feb 3, 2009, at 11:24 AM, Little K. wrote:

For some reason this outputs a “#” for each sport in kid.sports
instead
of the name… Would anyone know why?

looks like you have a ) where you should have a }

That’s just a result of me typing wrong on this forum, not causing the
problem. Its correct in my code.

tag ‘kids:kid_sport_list’ do |tag|
kid = tag.locals.kid
result = []
kid.sports.each do |sport|
result << sport.name
end
result.join(’ ')
end