sassをhamlテンプレートで動作させるのに問題があります。
最近、メインの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