我正在使用Sinatra,我正在尝试使用Slim作为CSS的HTML和Stylus .

我不确定这样做的正确方法是什么 . 我目前所做的工作(本地,我没有尝试过部署),但我想知道这是否是最有效的做事方式 .

我的 layout.slim 文件有:

styl:
   @import('style')

..在 head . 这是使用Stylus样式表的最佳方法,还是应该在sinatra app.rb中设置/ style路径?

我的代码如下:


这是我的 app.rb

require 'sinatra'       # ruby url route patterns framework
require 'slim'          # html templating
require 'stylus'        # css templating
require 'stylus/tilt'

get '/' do
  @page_title = "Home"
  slim :index
end

在views文件夹中,我有一个 layout.slim ,看起来像这样

html
  head
    title #{@page_title}

    styl:
      @import('style')

  body
    #header header in layout.slim

    #central-area
      == yield

    #footer

index.slim 看起来像这样

p this is the index which is 'yielded' in the layout.slim

在与 app.rb 相同的文件夹中,我有 style.styl

color-combo1()
  color white
  background-color red
color-combo2()
  color #eeeeee
  background-color blue
#header
  color-combo1()
  padding 5px
  width 100%
#central-area
  padding 0px 20px
  color #111111
#footer
  color-combo2()
  padding 5px