2007-08-23

render 方法

关键字: render

render(:text => string) 输出字符串:
render(:text => cookies[:test_cookies].to_s)
render(:text => "字符串")

render(:action => action_name)调用action()方法:
render(:action => :index)

render(:template => template_name)显示模板:
render(:template => "test/index")

render(:file => path)显示指定文件:
render(:file => "D:/ruby/projects/test/app/views/test/index.rhtml")
render(:file => "test/index",:use_full_path => true)

render(:nothing => true)返回空值:
render(:nothing => true)


动态生成模板并显示数据:
render  :inline => "", :locals => { :word => "World"},:type => "rhtml"

render(:partial => path)调用局部模板:
render(:partial => "partial/title", :object => @first_item)

评论
发表评论

您还没有登录,请登录后发表评论

simon_lin
搜索本博客
最近加入圈子
存档
最新评论