开发者

Rendering partial with locals in Haml?

开发者 https://www.devze.com 2023-02-16 10:06 出处:网络
I am learning Haml. My view files are like: show.html.haml: .content = render \'meeting_info\', :locals => { :info => @info }

I am learning Haml.

My view files are like:

show.html.haml:

.content
  = render 'meeting_info', :locals => { :info => @info }

and _meeting_info.html.haml:

.detai开发者_高级运维l
  %table
    %caption
      Meeting Informations of
      = info["meeting_name"]
...

When I tried running this I got an undefined local variable or method 'info' error.


Try this
Without :locals and :partial

.content
  = render 'meeting_info', :info => @info

No need to specify locals.

With :locals and :partial
You should specify locals in following case i.e specifying :partial for render

.content
  = render :partial => 'meeting_info', :locals => { :info => @info }


You would use the :locals option if you're calling render from a controller. When calling render from a view, you would simply do this:

= render 'meeting_info', :info => @info
0

精彩评论

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