Sha256: 2455a2ed479a397c46fa9220ddc634b6a547d6a49e5499bbfa4e25e64a775155

Contents?: true

Size: 1.55 KB

Versions: 2

Compression:

Stored size: 1.55 KB

Contents

require "ember_cli/capture"

module EmberRailsHelper
  def include_ember_index_html(name, &block)
    Warnings.warn_include_index_html

    render_ember_app(name, &block)
  end

  def render_ember_app(name, &block)
    markup_capturer = EmberCli::Capture.new(sprockets: self, &block)

    head, body = markup_capturer.capture

    render inline: EmberCli[name].sprockets.index_html(head: head, body: body)
  end

  def include_ember_script_tags(name, **options)
    Warnings.warn_asset_helper

    javascript_include_tag(*EmberCli[name].sprockets.javascript_assets, options)
  end

  def include_ember_stylesheet_tags(name, **options)
    Warnings.warn_asset_helper

    stylesheet_link_tag(*EmberCli[name].sprockets.stylesheet_assets, options)
  end

  module Warnings
    def self.warn_include_index_html
      warn <<-MSG.strip_heredoc
        The `include_ember_index_html` helper has been deprecated.

        Rename all invocations to `render_ember_app`
      MSG
    end

    def self.warn_asset_helper
      if Rails::VERSION::MAJOR < 4
        warn <<-MSG.strip_heredoc
          `ember-cli-rails` no longer supports Sprockets-based helpers for Rails
          versions below 4.0.

          Replace usage of
            * `include_ember_script_tags`
            * `include_ember_stylesheet_tags`

          with `render_ember_app` invocations.

          To learn more, please read:

          * https://github.com/thoughtbot/ember-cli-rails#configuring-the-ember-controller
          * https://github.com/thoughtbot/ember-cli-rails/pull/316
        MSG
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ember-cli-rails-0.5.8 app/helpers/ember_rails_helper.rb
ember-cli-rails-0.5.7 app/helpers/ember_rails_helper.rb