我index.haml工作正常使用,例如:HAML layout.haml和西納特拉不是URL工作參數
get '/about' do
haml :about
end
但是,如果我嘗試使用一個用戶參數,如:
get ':user/add' do
haml :add_item
end
layout.haml被忽略。
我試圖讓這個在我看來,像文件夾使用子目錄的工作:
/view/contact/add.haml
雖然它插入=產量內容,它不會顯示佈局.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看起來是這樣的:
的意見/ 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.
任何幫助將不勝感激。謝謝。
我不知道它的問題,但是我用獵槍發展
它幫助了我,謝謝。 – slowpoke 2013-12-05 08:30:14