Sha256: 1e30597f8b2b5b6c4bccc519af7cf05e373bc5c0b778676b964048845fafc553
Contents?: true
Size: 834 Bytes
Versions: 16
Compression:
Stored size: 834 Bytes
Contents
module Sinatra::AssetHelpers def stylesheet(s) s += '.css' unless s.include?('.css') s = asset_path(s) unless s =~ /^https?:\// or s =~ /^\/\/.+/ "<link rel='stylesheet' href='#{s}' />" end def javascript(s, &block) s += '.js' unless s.include?('.js') s = asset_path(s) unless s =~ /^https?:\// or s =~ /^\/\/.+/ html = "<script type='text/javascript' src='#{s}'>" if block.present? require 'haml' context = Object.new class << context include Haml::Helpers end context.init_haml_helpers html += context.capture_haml(&block) end html += '</script>' end def asset_path(source, options={}) source = ('/assets/' + source).gsub('//', '/').gsub('/assets/assets/', '/assets/') end def image_path(source) asset_path(source) end end
Version data entries
16 entries across 16 versions & 1 rubygems