NameError in using custom layout option in sinatra app

烈酒焚心 提交于 2019-12-11 08:19:52

问题


To use custom layout file in my app I'm using this following code,

set :views, File.dirname(__FILE__) + "/../views"
set :public_folder, File.dirname(__FILE__) + "/../public"
get '/' do
if !Db.empty? then
haml :home, {:layout => :nosetup-layout}
elsif request.ip == "127.0.0.1" then

haml :setup, {:layout => :nosetup-layout}

else
haml :nosetup, {:layout => :nosetup-layout}
end
end 

there seems to be a problem with the layout option

I get the following error

undefined local variable or method `layout' for #<TabPlayer::Server:0x000000024509c8>

So, where did I went wrong?


回答1:


Rename your layout to nosetup_layout (using an underscore).

Then just call:

haml :nosetup, {:layout => :nosetup_layout}


来源:https://stackoverflow.com/questions/11190208/nameerror-in-using-custom-layout-option-in-sinatra-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!