Sha256: b9aa385d519095de94cf0782619b64f1d24ed22426f3ab4ea728b6f11afc6995

Contents?: true

Size: 766 Bytes

Versions: 3

Compression:

Stored size: 766 Bytes

Contents

module SeajsHelper
  # generate seajs.use()
  def seajs_use(*modules)
    seajs_config = Rails.application.config.seajs

    if seajs_config.compiled?
      modules.map! { |m| seajs_config.family + '/' + m }
    else
      modules.map! { |m| '/assets/' + m }
    end

    html = <<-html
    <script>
    seajs.use(#{modules.to_s})
    </script>
    html

    html.html_safe
  end

  # include seajs script and map config
  def seajs_tag
    seajs_config = Rails.application.config.seajs

    html = <<-html
      <script src="/assets/sea-modules/#{seajs_config.seajs_path}"></script>
      <script>
      seajs.config({
        map: #{seajs_config.map_json || '[]'}
      })
      </script>
    html

    html.html_safe
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
seajs-rails-0.0.3 app/helpers/seajs_helper.rb
seajs-rails-0.0.2 app/helpers/seajs_helper.rb
seajs-rails-0.0.1 app/helpers/seajs_helper.rb