我有问题让我的萨姆工作与我的哈姆模板。Sinatra自定义SASS目录
最近,我在下面我主要sinatra.rb应用程序代码:
require 'sinatra'
require 'dm-core'
require 'dm-migrations'
require 'haml'
require 'sass'
require 'shotgun'
set :views, :sass => 'views/css', :haml => 'template', :default => 'views'
helpers do
def find_template(views, name, engine, &block)
_, folder = views.detect { |k,v| engine == Tilt[k] }
folder ||= views[:default]
super(folder, name, engine, &block)
end
end
get '/css/styles.css' do
sass :styles
end
get '/' do
haml :index
end
I have following application directory structure:
site
|site.rb
|-sass > styles.scss (my scss file generate css realtime using sass --watch sass:css command
|-css > styles.css
|-template > index.haml
我index.haml文件,该文件是在模板文件夹中呈现的罚款。
我index.haml模板:
!!! XML
!!!
%html
%head
%title Some title
%meta{"http-equiv" => "Content-Type", :content => "text/html; charset=utf-8"}
%link{"rel" => "stylesheet", "href" => "views/css/styles.css", "type" => "text/css"}
%body
%h1 Some h1
%p Some p
我已经把我的工作目录到一个你建议我。另一个问题是我应该把我的.css/.scss文件放在哪里?进入我的应用程序根目录? Atm im我的Shothun服务器产生以下错误: Errno :: ENOENT - 没有这样的文件或目录 - views/css/styles.sass: –
您应该将.scss文件放在您设置sass views目录的任何位置因为那是它寻找那些观点的地方。 –