Module: Pagy::Configurable
- Included in:
- Pagy
- Defined in:
- lib/pagy/modules/abilities/configurable.rb
Overview
Add configurstion methods
Instance Method Summary collapse
-
#dev_tools(wand_scale: 1) ⇒ Object
Generate the script and style tags to help development.
-
#sync_javascript(destination, *targets) ⇒ Object
Sync the pagy javascript targets.
-
#translate_with_the_slower_i18n_gem! ⇒ Object
Setup pagy for using the i18n gem.
Instance Method Details
#dev_tools(wand_scale: 1) ⇒ Object
Generate the script and style tags to help development
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/pagy/modules/abilities/configurable.rb', line 15 def dev_tools(wand_scale: 1) <<~HTML <script id="pagy-ai-widget"> #{ROOT.join('javascripts/ai_widget.js').read} </script> <script id="pagy-wand" data-scale="#{wand_scale}"> #{ROOT.join('javascripts/wand.js').read} </script> <style id="pagy-wand-default"> #{ROOT.join('stylesheets/pagy.css').read} </style> HTML end |
#sync_javascript(destination, *targets) ⇒ Object
Sync the pagy javascript targets
7 8 9 10 11 12 |
# File 'lib/pagy/modules/abilities/configurable.rb', line 7 def sync_javascript(destination, *targets) names = %w[pagy.mjs pagy.js pagy.js.map pagy.min.js] targets = names if targets.empty? targets.each { |filename| FileUtils.cp(ROOT.join('javascripts', filename), destination) } (names - targets).each { |filename| FileUtils.rm_f(File.join(destination, filename)) } end |
#translate_with_the_slower_i18n_gem! ⇒ Object
Setup pagy for using the i18n gem
30 31 32 33 34 |
# File 'lib/pagy/modules/abilities/configurable.rb', line 30 def translate_with_the_slower_i18n_gem! send(:remove_const, :I18n) send(:const_set, :I18n, ::I18n) ::I18n.load_path += Dir[ROOT.join('locales/*.yml')] end |