Sha256: e6ff8fb3266e463035f41ca564c7a5ca61903ab46eea586c89d6b461117c5d5a

Contents?: true

Size: 951 Bytes

Versions: 1

Compression:

Stored size: 951 Bytes

Contents

module SeajsHelper

  # get module name
  def seajs_modules(*modules)
    seajs_config = Rails.application.config.seajs

    modules.map! do |m|
      if m.start_with? '#'
        m[1..-1]
      else
        if seajs_config.compiled?
          seajs_config.family + '/' + m
        else
          '/assets/' + m
        end
      end
    end
    modules.to_s.html_safe
  end

  # generate seajs.use()
  def seajs_use(*modules)
    html = <<-html
    <script>
    seajs.use(#{modules_seajs_use(*modules)})
    </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

1 entries across 1 versions & 1 rubygems

Version Path
seajs-rails-0.0.8 app/helpers/seajs_helper.rb