better helper logic

This commit is contained in:
tdreyno 2009-10-01 11:44:21 -07:00
parent b35f026aba
commit 087f48c98d

View file

@ -25,22 +25,22 @@ module Middleman
path.include?("://") ? path : File.join(base_url, path) path.include?("://") ? path : File.join(base_url, path)
end end
def image_tag(path, options={}) def image_tag(path, params={})
options[:alt] ||= "" params[:alt] ||= ""
params = options.merge(:src => asset_url(path, self.images_dir)) params = params.merge(:src => asset_url(path, options.images_dir))
params = params.map { |k,v| %Q{#{k}="#{v}"}}.join(' ') params = params.map { |k,v| %Q{#{k}="#{v}"}}.join(' ')
"<img #{params} />" "<img #{params} />"
end end
def javascript_include_tag(path, options={}) def javascript_include_tag(path, params={})
params = options.merge(:src => asset_url(path, self.js_dir), :type => "text/javascript") params = params.merge(:src => asset_url(path, options.js_dir), :type => "text/javascript")
params = params.map { |k,v| %Q{#{k}="#{v}"}}.join(' ') params = params.map { |k,v| %Q{#{k}="#{v}"}}.join(' ')
"<script #{params}></script>" "<script #{params}></script>"
end end
def stylesheet_link_tag(path, options={}) def stylesheet_link_tag(path, params={})
options[:rel] ||= "stylesheet" params[:rel] ||= "stylesheet"
params = options.merge(:href => asset_url(path, self.css_dir), :type => "text/css") params = params.merge(:href => asset_url(path, options.css_dir), :type => "text/css")
params = params.map { |k,v| %Q{#{k}="#{v}"}}.join(' ') params = params.map { |k,v| %Q{#{k}="#{v}"}}.join(' ')
"<link #{params} />" "<link #{params} />"
end end