我的index.haml正常工作,例如:
get '/about' do
haml :about
end
Run Code Online (Sandbox Code Playgroud)
但是,如果我尝试使用如下的用户参数:
get ':user/add' do
haml :add_item
end
Run Code Online (Sandbox Code Playgroud)
layout.haml被忽略.
我试图使用我的视图文件夹中的子目录来使其工作,如:
/view/contact/add.haml
虽然它插入= yield内容,但它不会显示layout.haml css样式等.
所以我认为使用子目录是问题,并将我的所有hamls放在基本视图目录中.但是,似乎任何使用url参数(如get':user/add')都不会包含layout.haml.目前这是我做的测试:
myapp.rb
require "rubygems"
require "sinatra"
require "haml"
require "data_mapper"
require "pony"
get '/' do #works fine
haml :index
end
get '/:user_id/dashboard' do #recognizes the content but ignores layout.haml
haml :dashboard
end
Run Code Online (Sandbox Code Playgroud)
我的layout.haml看起来像这样:
意见/ layout.haml
!!!
%html
%head
%title Testing haml and sinatra
%link(rel="stylesheet" href="css/style.css")
%body
#wrapper
#header
%h1 HAML Test Template
%h2 Made with Sinatra and HAML! …Run Code Online (Sandbox Code Playgroud)