Last active
December 13, 2019 13:28
-
-
Save phillbaker/4652773 to your computer and use it in GitHub Desktop.
Sinatra-Assetpack + LESS (Twitter Bootstrap) demo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# app/css/app.less | |
.main { | |
border: 1 + 1px solid #eee; | |
border-radius: 3px; | |
padding: 1rem; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'bundler/setup' | |
require 'sinatra/base' | |
require 'sinatra/assetpack' | |
require 'less' | |
class App < Sinatra::Base | |
set :root, File.dirname(__FILE__) | |
register Sinatra::AssetPack | |
enable :inline_templates | |
assets do | |
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/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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source :rubygems | |
gem 'sinatra' | |
gem 'sinatra-assetpack' | |
gem 'json' | |
gem 'therubyracer' | |
gem 'less' |
Author
phillbaker
commented
Jan 28, 2013
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment