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

Version Path
fanforce-plugin-factory-0.40.0 lib/fanforce/plugin_factory/config/helpers/assets.rb
fanforce-plugin-factory-0.39.1 lib/fanforce/plugin_factory/config/helpers/assets.rb
fanforce-plugin-factory-0.39.0 lib/fanforce/plugin_factory/config/helpers/assets.rb
fanforce-plugin-factory-0.38.2 lib/fanforce/plugin_factory/config/helpers/assets.rb
fanforce-plugin-factory-0.38.1 lib/fanforce/plugin_factory/config/helpers/assets.rb
fanforce-plugin-factory-0.38.0 lib/fanforce/plugin_factory/config/helpers/assets.rb
fanforce-plugin-factory-0.37.1 lib/fanforce/plugin_factory/config/helpers/assets.rb
fanforce-plugin-factory-0.37.0 lib/fanforce/plugin_factory/config/helpers/assets.rb
fanforce-plugin-factory-0.36.0 lib/fanforce/plugin_factory/config/helpers/assets.rb
fanforce-plugin-factory-0.35.2 lib/fanforce/plugin_factory/config/helpers/assets.rb
fanforce-plugin-factory-0.35.1 lib/fanforce/plugin_factory/config/helpers/assets.rb
fanforce-plugin-factory-0.35.0 lib/fanforce/plugin_factory/config/helpers/assets.rb
fanforce-plugin-factory-0.34.2 lib/fanforce/plugin_factory/config/helpers/assets.rb
fanforce-plugin-factory-0.34.1 lib/fanforce/plugin_factory/config/helpers/assets.rb
fanforce-plugin-factory-0.34.0 lib/fanforce/plugin_factory/config/helpers/assets.rb
fanforce-plugin-factory-0.33.0 lib/fanforce/plugin_factory/config/helpers/assets.rb