Skip to content

Instantly share code, notes, and snippets.

@phillbaker
Last active December 13, 2019 13:28

Revisions

  1. phillbaker revised this gist Jan 28, 2013. 2 changed files with 3 additions and 3 deletions.
    1 change: 1 addition & 0 deletions app.less
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,4 @@
    # app/css/app.less
    .main {
    border: 1 + 1px solid #eee;
    border-radius: 3px;
    5 changes: 2 additions & 3 deletions app.rb
    Original file line number Diff line number Diff line change
    @@ -8,20 +8,19 @@

    class App < Sinatra::Base
    set :root, File.dirname(__FILE__)
    set :logging, true
    register Sinatra::AssetPack

    enable :inline_templates

    assets do
    css_dir = '' # Same directory
    css_dir = 'app/css' # Same directory
    serve '/css', :from => css_dir

    # Add all the paths that Less should look in for @import'ed files
    Less.paths << File.join(App.root, css_dir)

    css :styles, '/css/styles.css', [
    '/css/bootstrap.css', # bootstrap.less
    # '/css/bootstrap.css', # bootstrap.less
    '/css/app.css'
    ]

  2. phillbaker created this gist Jan 28, 2013.
    8 changes: 8 additions & 0 deletions Gemfile
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    source :rubygems

    gem 'sinatra'
    gem 'sinatra-assetpack'

    gem 'json'
    gem 'therubyracer'
    gem 'less'
    5 changes: 5 additions & 0 deletions app.less
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    .main {
    border: 1 + 1px solid #eee;
    border-radius: 3px;
    padding: 1rem;
    }
    49 changes: 49 additions & 0 deletions app.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,49 @@
    require 'rubygems'
    require 'bundler/setup'

    require 'sinatra/base'
    require 'sinatra/assetpack'

    require 'less'

    class App < Sinatra::Base
    set :root, File.dirname(__FILE__)
    set :logging, true
    register Sinatra::AssetPack

    enable :inline_templates

    assets do
    css_dir = '' # Same directory
    serve '/css', :from => css_dir

    # Add all the paths that Less should look in for @import'ed files
    Less.paths << File.join(App.root, css_dir)

    css :styles, '/css/styles.css', [
    '/css/bootstrap.css', # bootstrap.less
    '/css/app.css'
    ]

    css_compression :less
    end

    get '/' do
    erb :index
    end

    run! if app_file == $0
    end

    __END__

    @@ index
    <html>
    <head>
    <%= css :styles %>
    </head>
    <body>
    <h1>Hello!</h1>
    <p class="main"><a href="#" class="btn">Link</a></p>
    </body>
    </html>