asset helpers
This commit is contained in:
parent
e3c6ef78c9
commit
e670940909
4 changed files with 17 additions and 14 deletions
5
.gitmodules
vendored
5
.gitmodules
vendored
|
@ -9,7 +9,4 @@
|
||||||
url = git://github.com/brynary/rack-test.git
|
url = git://github.com/brynary/rack-test.git
|
||||||
[submodule "vendor/sinatra-content-for"]
|
[submodule "vendor/sinatra-content-for"]
|
||||||
path = vendor/sinatra-content-for
|
path = vendor/sinatra-content-for
|
||||||
url = git://github.com/foca/sinatra-content-for.git
|
url = git://github.com/foca/sinatra-content-for.git
|
||||||
[submodule "vendor/sinatra-helpers"]
|
|
||||||
path = vendor/sinatra-helpers
|
|
||||||
url = git://github.com/sbfaulkner/sinatra-helpers.git
|
|
|
@ -12,9 +12,6 @@ require File.join(File.dirname(__FILE__), '..', 'vendor', 'sinatra-maruku', 'lib
|
||||||
# Include content_for support
|
# Include content_for support
|
||||||
require File.join(File.dirname(__FILE__), '..', 'vendor', 'sinatra-content-for', 'lib', 'sinatra', 'content_for')
|
require File.join(File.dirname(__FILE__), '..', 'vendor', 'sinatra-content-for', 'lib', 'sinatra', 'content_for')
|
||||||
|
|
||||||
# Include common haml/html helper support
|
|
||||||
require File.join(File.dirname(__FILE__), '..', 'vendor', 'sinatra-helpers', 'lib', 'sinatra-helpers', 'haml')
|
|
||||||
|
|
||||||
class Middleman < Sinatra::Base
|
class Middleman < Sinatra::Base
|
||||||
set :app_file, __FILE__
|
set :app_file, __FILE__
|
||||||
set :static, true
|
set :static, true
|
||||||
|
@ -24,9 +21,6 @@ class Middleman < Sinatra::Base
|
||||||
helpers Sinatra::Markaby
|
helpers Sinatra::Markaby
|
||||||
helpers Sinatra::Maruku
|
helpers Sinatra::Maruku
|
||||||
helpers Sinatra::ContentFor
|
helpers Sinatra::ContentFor
|
||||||
helpers Sinatra::Helpers::Haml::Forms
|
|
||||||
helpers Sinatra::Helpers::Haml::Links
|
|
||||||
helpers Sinatra::Helpers::Haml::Partials
|
|
||||||
|
|
||||||
def self.run!(options={}, &block)
|
def self.run!(options={}, &block)
|
||||||
set options
|
set options
|
||||||
|
@ -51,7 +45,6 @@ class Middleman < Sinatra::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
configure do
|
configure do
|
||||||
puts "config yo"
|
|
||||||
Compass.configuration do |config|
|
Compass.configuration do |config|
|
||||||
config.project_path = Dir.pwd
|
config.project_path = Dir.pwd
|
||||||
config.sass_dir = File.join(File.basename(self.views), "stylesheets")
|
config.sass_dir = File.join(File.basename(self.views), "stylesheets")
|
||||||
|
|
|
@ -15,7 +15,21 @@ Middleman.helpers do
|
||||||
classes.join(' ')
|
classes.join(' ')
|
||||||
end
|
end
|
||||||
|
|
||||||
def asset_url(path, tld_length = 1)
|
def asset_url(path)
|
||||||
"/#{path}"
|
path.include?("://") ? path : "/#{path}"
|
||||||
|
end
|
||||||
|
|
||||||
|
def image_tag(path, options={})
|
||||||
|
options[:alt] ||= ""
|
||||||
|
capture_haml do
|
||||||
|
haml_tag :img, options.merge(:src => asset_url(path))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def stylesheet_link_tag(path, options={})
|
||||||
|
options[:rel] ||= "stylesheet"
|
||||||
|
capture_haml do
|
||||||
|
haml_tag :link, options.merge(:href => asset_url(path), :type => "text/css")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
1
vendor/sinatra-helpers
vendored
1
vendor/sinatra-helpers
vendored
|
@ -1 +0,0 @@
|
||||||
Subproject commit 65d5060ad8cdff6b12631878d97486114d195376
|
|
Loading…
Add table
Reference in a new issue