asset helpers

This commit is contained in:
tdreyno 2009-08-04 16:32:01 -07:00
parent e3c6ef78c9
commit e670940909
4 changed files with 17 additions and 14 deletions

5
.gitmodules vendored
View file

@ -9,7 +9,4 @@
url = git://github.com/brynary/rack-test.git
[submodule "vendor/sinatra-content-for"]
path = vendor/sinatra-content-for
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
url = git://github.com/foca/sinatra-content-for.git

View file

@ -12,9 +12,6 @@ require File.join(File.dirname(__FILE__), '..', 'vendor', 'sinatra-maruku', 'lib
# Include content_for support
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
set :app_file, __FILE__
set :static, true
@ -24,9 +21,6 @@ class Middleman < Sinatra::Base
helpers Sinatra::Markaby
helpers Sinatra::Maruku
helpers Sinatra::ContentFor
helpers Sinatra::Helpers::Haml::Forms
helpers Sinatra::Helpers::Haml::Links
helpers Sinatra::Helpers::Haml::Partials
def self.run!(options={}, &block)
set options
@ -51,7 +45,6 @@ class Middleman < Sinatra::Base
end
configure do
puts "config yo"
Compass.configuration do |config|
config.project_path = Dir.pwd
config.sass_dir = File.join(File.basename(self.views), "stylesheets")

View file

@ -15,7 +15,21 @@ Middleman.helpers do
classes.join(' ')
end
def asset_url(path, tld_length = 1)
"/#{path}"
def asset_url(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

@ -1 +0,0 @@
Subproject commit 65d5060ad8cdff6b12631878d97486114d195376