Skip to content

Commit ef6273f

Browse files
authored
Extract a helpers (#160)
1 parent 8cc5407 commit ef6273f

File tree

9 files changed

+87
-71
lines changed

9 files changed

+87
-71
lines changed

lib/phlex/rails/helpers.rb

Lines changed: 9 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,18 @@
11
# frozen_string_literal: true
22

33
module Phlex::Rails::Helpers
4-
autoload :Tag, "phlex/rails/helpers/tag"
4+
autoload :ActionCableMetaTag, "phlex/rails/helpers/action_cable_meta_tag"
5+
autoload :ActionName, "phlex/rails/helpers/action_name"
6+
autoload :AssetPath, "phlex/rails/helpers/asset_path"
7+
autoload :AssetURL, "phlex/rails/helpers/asset_url"
8+
autoload :AudioPath, "phlex/rails/helpers/audio_path"
9+
autoload :AudioTag, "phlex/rails/helpers/audio_tag"
10+
autoload :AudioURL, "phlex/rails/helpers/audio_url"
11+
autoload :AutoDiscoveryLinkTag, "phlex/rails/helpers/auto_discovery_link_tag"
512
autoload :Routes, "phlex/rails/helpers/routes"
13+
autoload :Tag, "phlex/rails/helpers/tag"
614
autoload :TurboStream, "phlex/rails/helpers/turbo_stream"
715

8-
module ActionCableMetaTag
9-
extend Phlex::Rails::HelperMacros
10-
11-
# @!method action_cable_meta_tag
12-
# Outputs an "action-cable-url" meta tag with the value of the URL specified in your configuration. Ensure this is above your JavaScript tag:
13-
# @see https://api.rubyonrails.org/classes/ActionCable/Helpers/ActionCableHelper.html#method-i-action_cable_meta_tag
14-
# @return [nil]
15-
define_output_helper :action_cable_meta_tag
16-
end
17-
18-
module ActionName
19-
extend Phlex::Rails::HelperMacros
20-
21-
# @!method action_name
22-
# @return [String] the name of the controller action, e.g. <code>"index"</code>
23-
# @see https://api.rubyonrails.org/classes/AbstractController/Base.html#method-i-action_name
24-
define_value_helper :action_name
25-
end
26-
27-
module AssetPath
28-
extend Phlex::Rails::HelperMacros
29-
30-
# @!method asset_path(source, host: nil, protocol: nil, type: nil, skip_pipeline: nil, extname: nil)
31-
# @param source [String]
32-
# @param host [String]
33-
# @param protocol [String] e.g. <code>"https"</code>
34-
# @param type [Symbol] e.g. <code>:javascript</code>
35-
# @param skip_pipeline [bool]
36-
# @param extname [String] e.g. <code>".js"</code>
37-
# @see https://api.rubyonrails.org/classes/ActionView/Helpers/AssetUrlHelper.html#method-i-asset_path
38-
define_value_helper :asset_path
39-
end
40-
41-
module AssetURL
42-
extend Phlex::Rails::HelperMacros
43-
44-
# @!method asset_url(...)
45-
define_value_helper :asset_url
46-
end
47-
48-
module AudioPath
49-
extend Phlex::Rails::HelperMacros
50-
51-
# @!method audio_path(...)
52-
define_value_helper :audio_path
53-
end
54-
55-
module AudioTag
56-
extend Phlex::Rails::HelperMacros
57-
58-
# @!method audio_tag(...)
59-
# @return [nil]
60-
define_output_helper :audio_tag
61-
end
62-
63-
module AudioURL
64-
extend Phlex::Rails::HelperMacros
65-
66-
# @!method audio_url(...)
67-
define_value_helper :audio_url
68-
end
69-
70-
module AutoDiscoveryLinkTag
71-
extend Phlex::Rails::HelperMacros
72-
73-
# @!method auto_discovery_link_tag(...)
74-
# @return [nil]
75-
define_output_helper :auto_discovery_link_tag
76-
end
77-
7816
module BuildTagValues
7917
extend Phlex::Rails::HelperMacros
8018

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# frozen_string_literal: true
2+
3+
module Phlex::Rails::Helpers::ActionCableMetaTag
4+
extend Phlex::Rails::HelperMacros
5+
6+
# @!method action_cable_meta_tag
7+
# Outputs an "action-cable-url" meta tag with the value of the URL specified in your configuration. Ensure this is above your JavaScript tag:
8+
# @see https://api.rubyonrails.org/classes/ActionCable/Helpers/ActionCableHelper.html#method-i-action_cable_meta_tag
9+
# @return [nil]
10+
define_output_helper :action_cable_meta_tag
11+
end
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# frozen_string_literal: true
2+
3+
module Phlex::Rails::Helpers::ActionName
4+
extend Phlex::Rails::HelperMacros
5+
6+
# @!method action_name
7+
# @return [String] the name of the controller action, e.g. <code>"index"</code>
8+
# @see https://api.rubyonrails.org/classes/AbstractController/Base.html#method-i-action_name
9+
define_value_helper :action_name
10+
end
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# frozen_string_literal: true
2+
3+
module Phlex::Rails::Helpers::AssetPath
4+
extend Phlex::Rails::HelperMacros
5+
6+
# @!method asset_path(source, host: nil, protocol: nil, type: nil, skip_pipeline: nil, extname: nil)
7+
# @param source [String]
8+
# @param host [String]
9+
# @param protocol [String] e.g. <code>"https"</code>
10+
# @param type [Symbol] e.g. <code>:javascript</code>
11+
# @param skip_pipeline [bool]
12+
# @param extname [String] e.g. <code>".js"</code>
13+
# @see https://api.rubyonrails.org/classes/ActionView/Helpers/AssetUrlHelper.html#method-i-asset_path
14+
define_value_helper :asset_path
15+
end
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# frozen_string_literal: true
2+
3+
module Phlex::Rails::Helpers::AssetURL
4+
extend Phlex::Rails::HelperMacros
5+
6+
# @!method asset_url(...)
7+
define_value_helper :asset_url
8+
end
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# frozen_string_literal: true
2+
3+
module Phlex::Rails::Helpers::AudioPath
4+
extend Phlex::Rails::HelperMacros
5+
6+
# @!method audio_path(...)
7+
define_value_helper :audio_path
8+
end
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# frozen_string_literal: true
2+
3+
module Phlex::Rails::Helpers::AudioTag
4+
extend Phlex::Rails::HelperMacros
5+
6+
# @!method audio_tag(...)
7+
# @return [nil]
8+
define_output_helper :audio_tag
9+
end
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# frozen_string_literal: true
2+
3+
module Phlex::Rails::Helpers::AudioURL
4+
extend Phlex::Rails::HelperMacros
5+
6+
# @!method audio_url(...)
7+
define_value_helper :audio_url
8+
end
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# frozen_string_literal: true
2+
3+
module Phlex::Rails::Helpers::AutoDiscoveryLinkTag
4+
extend Phlex::Rails::HelperMacros
5+
6+
# @!method auto_discovery_link_tag(...)
7+
# @return [nil]
8+
define_output_helper :auto_discovery_link_tag
9+
end

0 commit comments

Comments
 (0)