lib/middleman/helpers.rb in middleman-0.9.17 vs lib/middleman/helpers.rb in middleman-0.9.18

- old
+ new

@@ -1,6 +1,13 @@ module Middleman + class Base + def self.asset_url(path, prefix="", request=nil) + base_url = File.join(self.http_prefix, prefix) + path.include?("://") ? path : File.join(base_url, path) + end + end + module Helpers def page_classes(*additional) path = request.path_info path << options.index_file if path.match(%r{/$}) path.gsub!(%r{^/}, '') @@ -12,18 +19,17 @@ classes << "index" if classes.empty? classes += additional unless additional.empty? classes.join(' ') end + def asset_url(path, prefix="") + self.class.asset_url(path, prefix, request) + end + def link_to(title, url="#", params={}) params.merge!(:href => url) params = params.map { |k,v| %Q{#{k}="#{v}"}}.join(' ') %Q{<a #{params}>#{title}</a>} - end - - def asset_url(path, prefix="") - base_url = File.join(options.http_prefix, prefix) - path.include?("://") ? path : File.join(base_url, path) end def image_tag(path, params={}) params[:alt] ||= "" params = params.merge(:src => asset_url(path, options.images_dir))