# Custom Radiant Tags

**URL:** <https://www.ruby-forum.com/t/custom-radiant-tags/159335>\
**Category:** Radiant CMS\
**Created:** [February 3, 2009, 5:12pm UTC](https://www.ruby-forum.com/t/custom-radiant-tags/159335 "2009-02-03T17:12:50Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![littleknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/9fc29f/32.png) [@littleknown](https://www.ruby-forum.com/u/littleknown)\
**Post date:** [February 3, 2009, 5:12pm UTC](https://www.ruby-forum.com/t/custom-radiant-tags/159335/1 "2009-02-03T17:12:50Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![littleknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/9fc29f/32.png) [@littleknown](https://www.ruby-forum.com/u/littleknown)\
**Post date:** [February 3, 2009, 5:18pm UTC](https://www.ruby-forum.com/t/custom-radiant-tags/159335/2 "2009-02-03T17:18:35Z")

</div>

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 }

---

<div class="post-metadata">

**Author:** ![littleknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/9fc29f/32.png) [@littleknown](https://www.ruby-forum.com/u/littleknown)\
**Post date:** [February 3, 2009, 5:24pm UTC](https://www.ruby-forum.com/t/custom-radiant-tags/159335/3 "2009-02-03T17:24:47Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![littleknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/9fc29f/32.png) [@littleknown](https://www.ruby-forum.com/u/littleknown)\
**Post date:** [February 3, 2009, 5:31pm UTC](https://www.ruby-forum.com/t/custom-radiant-tags/159335/4 "2009-02-03T17:31:31Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![littleknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/9fc29f/32.png) [@littleknown](https://www.ruby-forum.com/u/littleknown)\
**Post date:** [February 3, 2009, 6:07pm UTC](https://www.ruby-forum.com/t/custom-radiant-tags/159335/5 "2009-02-03T18:07:39Z")

</div>

Thank you, very helpful!

---

<div class="post-metadata">

**Author:** ![littleknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/9fc29f/32.png) [@littleknown](https://www.ruby-forum.com/u/littleknown)\
**Post date:** [February 3, 2009, 5:34pm UTC](https://www.ruby-forum.com/t/custom-radiant-tags/159335/6 "2009-02-03T17:34:27Z")

</div>

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
