开发者

Unexpected render partial with locals behaviour

I have a partial with yeild blocks, which I set using content_for, when I render partial I am also trying to pass in locals. The locals never get picked up in the partial.

<%= render :partial => 'shared/block', :locals => { :cssclass => 'medium' } %>

When I try to access the partial using

<%= :cssclass %>

All I get is the bare "cssclass" as a string rather than the variable开发者_开发技巧 I have set it to. Can you not use content_for and render partial at the same time?

Update I tried rendering a partial with locals, no yield or content_for and the the values I setup while rendering the partial are getting picked up. Is there something I am missing?


use <%= cssclass %> instead of symbol. locals set a variable, not a symbol, and when you output symbol it is just converted to string.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜