class Htmx::Generators::InstallGenerator
Constants
- SPROCKETS_SETUP
- WEBPACKER_SETUP
Public Instance Methods
setup()
click to toggle source
Setup HTMX
# File lib/generators/htmx/install_generator.rb, line 12 def setup if webpacker? setup_webpacker else setup_sprockets end end
Private Instance Methods
manifest(javascript_dir)
click to toggle source
# File lib/generators/htmx/install_generator.rb, line 26 def manifest(javascript_dir) Pathname.new(destination_root).join(javascript_dir, 'application.js') end
setup_sprockets()
click to toggle source
# File lib/generators/htmx/install_generator.rb, line 30 def setup_sprockets manifest = manifest('app/assets/javascripts') if manifest.exist? append_file manifest, "\n#{SPROCKETS_SETUP}" else create_file manifest, SPROCKETS_SETUP end end
setup_webpacker()
click to toggle source
# File lib/generators/htmx/install_generator.rb, line 40 def setup_webpacker `yarn add htmx.org` manifest = manifest(webpack_source_path) if manifest.exist? append_file(manifest, "\n#{WEBPACKER_SETUP}") else create_file(manifest, WEBPACKER_SETUP) end end
webpack_source_path()
click to toggle source
# File lib/generators/htmx/install_generator.rb, line 52 def webpack_source_path (Webpacker.try(:config).try(:source_entry_path) || Webpacker::Configuration.source_path.join( Webpacker::Configuration.entry_path ) ).relative_path_from(::Rails.root).to_s end
webpacker?()
click to toggle source
# File lib/generators/htmx/install_generator.rb, line 22 def webpacker? !!defined?(Webpacker) end