Sha256: 4e3b15f610c19ca49c0f8cedd173c9ebaab87268b4e3be62980c3a1ec40168d1

Contents?: true

Size: 1.79 KB

Versions: 8

Compression:

Stored size: 1.79 KB

Contents

require "action_controller"
require "action_controller/metal/renderers"
require "execjs"
require "execjs-rails"
require "jquery-rails"
require "sprockets-coffee-react"
require "react-rails"
require "react/source"
require "backbone-rails"
require "underscore-string-rails"
require "sass"
require "sass-rails"
require "foundation-rails"

module Revelry
  module Core
    class Engine < ::Rails::Engine
      ROUTER_ASSET = 'revelry/router/router'

      # Require the route config to load before we load the router assets
      # (otherwise, route table is empty)
      initializer 'revelry.dependent_on_routes', after: "sprockets.environment" do
        if Rails.application.assets.respond_to?(:register_preprocessor)
          routes = Rails.root.join('config','routes.rb')
          Rails.application.assets.register_preprocessor 'application/javascript', :'revelry.dependent_on_routes' do |ctx,data|
            ctx.depend_on(routes) if ctx.logical_path == ROUTER_ASSET
            data
          end
        end
      end

      # Enable controllers to respond to .props format, which returns the same
      # props that execjs uses for serverside render (as a JSON object)
      initializer "revelry.setup_props_renderer", :group => :all do |app|
        Mime::Type.register "text/reactprops", :props

        ActionController.add_renderer :props do |foo, opts|
          self.response_body = render_to_string template: Revelry::Core::PropsTemplate.new('', 'path', ActionView::Template.registered_template_handler(:erb), format: Mime[:erb], virtual_path: 'path')
        end
      end

      initializer 'revelry.set_react_version', before: 'react_rails.setup_vendor' do |app|
        app.config.react.addons = true
        app.config.react.variant = (::Rails.env.production? ? :production : :development)
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
revelry_core-0.1.6.8 lib/revelry_core/engine.rb
revelry_core-0.1.6.7 lib/revelry_core/engine.rb
revelry_core-0.1.6.6 lib/revelry_core/engine.rb
revelry_core-0.1.6.5 lib/revelry_core/engine.rb
revelry_core-0.1.6.4 lib/revelry_core/engine.rb
revelry_core-0.1.6.3 lib/revelry_core/engine.rb
revelry_core-0.1.6.2 lib/revelry_core/engine.rb
revelry_core-0.1.6.1 lib/revelry_core/engine.rb