Sha256: 3b5b7aee43c93e2599fcdbcb526d12179128902751c45edc98e832b165851d43

Contents?: true

Size: 816 Bytes

Versions: 2

Compression:

Stored size: 816 Bytes

Contents

module SeajsHelper
  # generate seajs.use()
  # if you use a module in base dir,please add #
  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

2 entries across 2 versions & 1 rubygems

Version Path
seajs-rails-0.0.5 app/helpers/seajs_helper.rb
seajs-rails-0.0.4 app/helpers/seajs_helper.rb