Module: Optipipe::TagHelper
- Defined in:
- lib/optipipe/helpers/tag_helper.rb
Instance Method Summary collapse
-
#optipipe_javascript_include_tag(*args) ⇒ Object
options mapper_conditions: Limiting conditions when select mapper.
-
#optipipe_stylesheet_link_tag(*args) ⇒ Object
options mapper_conditions: Limiting conditions when select mapper.
Instance Method Details
#optipipe_javascript_include_tag(*args) ⇒ Object
options
mapper_conditions: Limiting conditions when select mapper.
default: A mapper used when there aren't any one meeting a condition. This value is controller_path.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/optipipe/helpers/tag_helper.rb', line 6 def optipipe_javascript_include_tag(*args) # set args = args[0] || {} = args[1] || {} mapper_conditions = .delete(:mapper_conditions) || {} mapper_conditions.except!('controller_path', 'load_files', 'after_onload') # Using several key names at mapper_conditions are not allowed. mapper = get_mapper(Optipipe::Mapper.get_javascript_mappers(controller.controller_path), mapper_conditions) # default_mapper mapper = (Optipipe::Mapper.get_javascript_mappers([:default]) || []).first if mapper.blank? return if mapper.blank? script = (mapper['load_files'] || []).map do |file_name| javascript_include_tag("optipipe/precompiles/#{file_name}", ) end.join("\n").html_safe # after onload paths = (mapper['after_onload'] || []).map do |file_name| asset_path("optipipe/precompiles/#{file_name}") end script += render(partial: 'optipipe/after_onload', locals: {paths: paths}) if paths.present? script end |
#optipipe_stylesheet_link_tag(*args) ⇒ Object
options
mapper_conditions: Limiting conditions when select mapper.
default: A mapper used when there aren't any one meeting a condition. This value is controller_path.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/optipipe/helpers/tag_helper.rb', line 36 def optipipe_stylesheet_link_tag(*args) # set args = args[0] || {} = args[1] || {} mapper_conditions = .delete(:mapper_conditions) || {} mapper_conditions.except!('controller_path', 'load_files') # Using several key names at mapper_conditions are not allowed. mapper = get_mapper(Optipipe::Mapper.get_stylesheet_mappers(controller.controller_path), mapper_conditions) # default_mapper mapper = (Optipipe::Mapper.get_stylesheet_mappers([:default]) || []).first if mapper.blank? return if mapper.blank? (mapper['load_files'] || []).map do |file_name| stylesheet_link_tag("optipipe/precompiles/#{file_name}", {media: 'all'}.merge()) end.join.html_safe end |