Sha256: a2351414713b05de5c58e6367b8f1ebd744c54542ccf5e3f39bb98ce6fea24c8
Contents?: true
Size: 1.38 KB
Versions: 9
Compression:
Stored size: 1.38 KB
Contents
module Blacklight class Assets < Rails::Generators::Base source_root File.expand_path('../templates', __FILE__) # This could be skipped if you want to use webpacker def add_javascript_dependencies gem 'bootstrap-sass', '~> 3.0' gem 'twitter-typeahead-rails', '0.11.1.pre.corejavascript' end def assets copy_file "blacklight.scss", "app/assets/stylesheets/blacklight.scss" return if has_blacklight_assets? contents = "\n//\n// Required by Blacklight\n" contents += "//= require jquery\n" if needs_jquery? contents += "//= require blacklight/blacklight\n" marker = if turbolinks? '//= require turbolinks' elsif needs_jquery? '//= require rails-ujs' else '//= require jquery_ujs' end insert_into_file "app/assets/javascripts/application.js", :after => marker do contents end end # This is not a default in Rails 5.1 def add_jquery gem 'jquery-rails' if needs_jquery? end private def needs_jquery? Rails.version >= '5.1' end def turbolinks? @turbolinks ||= IO.read("app/assets/javascripts/application.js").include?('turbolinks') end def has_blacklight_assets? IO.read("app/assets/javascripts/application.js").include?('blacklight/blacklight') end end end
Version data entries
9 entries across 9 versions & 1 rubygems