Sha256: 1ba1839a4fef0b698a0182185dfbf92bdf35b4a693c3adf427881c733a123dad

Contents?: true

Size: 876 Bytes

Versions: 1

Compression:

Stored size: 876 Bytes

Contents

module EvilBlocks
  # Change Slim options to support @data-role shortcut.
  def self.install_to_slim!
    # Add @data-role alias to Slim.
    #
    # Copy from role-rails by Sasha Koss.
    # https://github.com/kossnocorp/role-rails
    shortcut = Slim::Parser.options[:shortcut]
    shortcut['@']  = { attr: 'data-role' }
    shortcut['@@'] = { attr: 'data-block' }
    Slim::Engine.options[:merge_attrs]['data-role']  = ' '
    Slim::Engine.options[:merge_attrs]['data-block'] = ' '
  end

  # Add assets paths to standalone Sprockets environment.
  def self.install(sprockets)
    sprockets.append_path(Pathname(__FILE__).dirname)
  end

  if defined? ::Rails
    class Engine < ::Rails::Engine
      initializer 'evil-blocks' do
        EvilBlocks.install(Rails.application.assets)
        EvilBlocks.install_to_slim! if defined?(Slim::Parser)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
evil-blocks-rails-0.6.3 lib/evil-blocks-rails.rb