私の 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 スタイルなどは表示されません。
そのため、サブディレクトリの使用が問題であると考え、すべての haml をベース ビュー ディレクトリに配置しました。ただし、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は次のようになります:
ビュー/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.
どんな助けでも大歓迎です。ありがとう。
関係あるかわかりませんが、開発にはショットガンを使用しています