【发布时间】:2012-07-20 22:44:25
【问题描述】:
我的 index.haml 可以正常工作,例如:
get '/about' do
haml :about
end
但如果我尝试使用如下用户参数:
get ':user/add' do
haml :add_item
end
layout.haml 被忽略。
我试图使用我的视图文件夹中的子目录来让它工作,例如:
/view/contact/add.haml
虽然插入=yield内容,但不会显示layout.haml css样式等
所以我认为使用子目录是问题所在,并将我的所有 hamls 放在基本视图目录中。然而,似乎任何使用像 get ':user/add' 这样的 url 参数的东西都不会包含 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
我的 layout.haml 看起来像这样:
views/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!
#navigation
%h1 Navigation
#sidebar
%h1 Sidebar
#content
=yield
#footer
%p
This is the footer.
任何帮助将不胜感激。谢谢。
我不知道这是否重要,但我正在使用霰弹枪进行开发
【问题讨论】: