Module: Wallaby::ApplicationHelper

Defined in:
lib/helpers/wallaby/application_helper.rb

Overview

Application helper

Instance Method Summary collapse

Instance Method Details

#javascript_include_tag(*sources) ⇒ Object

Add turbolinks options when it’s enabled



29
30
31
32
33
34
35
36
37
38
# File 'lib/helpers/wallaby/application_helper.rb', line 29

def javascript_include_tag(*sources)
  default_options =
    if Wallaby.configuration.features.turbolinks_enabled
      { 'data-turbolinks-track' => true, 'data-turbolinks-eval' => false }
    else
      {}
    end
  options = default_options.merge!(sources.extract_options!.stringify_keys)
  super(*sources, options)
end

Add turbolinks options when it’s enabled



17
18
19
20
21
22
23
24
25
26
# File 'lib/helpers/wallaby/application_helper.rb', line 17

def stylesheet_link_tag(*sources)
  default_options =
    if Wallaby.configuration.features.turbolinks_enabled
      { 'data-turbolinks-track' => true }
    else
      {}
    end
  options = default_options.merge!(sources.extract_options!.stringify_keys)
  super(*sources, options)
end

#url_for(options = nil) ⇒ Object

Override ‘actionview/lib/action_view/routing_url_for.rb#url_for` to handle the url_for properly for wallaby engine



6
7
8
9
10
11
12
13
14
# File 'lib/helpers/wallaby/application_helper.rb', line 6

def url_for(options = nil)
  # possible Hash or Parameters
  if options.respond_to?(:to_h) \
    && options[:resources].present? && options[:action].present?
    UrlFor.handle wallaby_engine, options
  else
    super options
  end
end