我在使用我的 haml 模板进行 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