在Haml与本地人一起渲染? [英] Rendering partial with locals in Haml?

查看:93
本文介绍了在Haml与本地人一起渲染?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习哈姆尔.

我的视图文件如下:

show.html.haml:

show.html.haml:

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

和_meeting_info.html.haml:

and _meeting_info.html.haml:

.detail
  %table
    %caption
      Meeting Informations of
      = info["meeting_name"]
...

当我尝试运行此程序时,出现了undefined local variable or method 'info'错误.

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

推荐答案

尝试一下
没有:locals:partial

Try this
Without :locals and :partial

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

无需指定本地人.

使用:locals:partial
在以下情况下,您应该指定本地人,即为渲染指定:partial

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 }

这篇关于在Haml与本地人一起渲染?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆