# Who's invoking yeild?

**URL:** <https://www.ruby-forum.com/t/whos-invoking-yeild/183928>\
**Category:** Rails\
**Created:** [February 22, 2010, 7:25pm UTC](https://www.ruby-forum.com/t/whos-invoking-yeild/183928 "2010-02-22T19:25:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ralphshnelvar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e19adc/32.png) [@ralphshnelvar](https://www.ruby-forum.com/u/ralphshnelvar)\
**Post date:** [February 22, 2010, 7:25pm UTC](https://www.ruby-forum.com/t/whos-invoking-yeild/183928/1 "2010-02-22T19:25:01Z")

</div>

This is a question that, I think,. straddles both Ruby and RoR. I’m  
gonna post it here.

In some sample code, I see the following in the section:

```
<%= yield(:head) %>

```

I see that the yield is returning something (i.e. “:head”) … but why?  
And to whom? How can I tell?

---

<div class="post-metadata">

**Author:** ![ralphshnelvar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e19adc/32.png) [@ralphshnelvar](https://www.ruby-forum.com/u/ralphshnelvar)\
**Post date:** [February 22, 2010, 7:41pm UTC](https://www.ruby-forum.com/t/whos-invoking-yeild/183928/2 "2010-02-22T19:41:48Z")

</div>

\<%= yield(:head) %\> (presumably in one of your layouts) yields to any  
view  
doing something like

\<% content\_for :head do -%\>

This text will be in the location of the html where \<%=yield(:head)%\> is

\<% end %\>

This is useful for doing things like include genormous javascript  
libraries  
like tinymce only when needed in views that are editing with wysiwyg  
text  
boxes.

-ben
