Module: ApplicationConfig::ViewHelpers
- Defined in:
- lib/application_config/view_helpers.rb
Instance Method Summary collapse
Instance Method Details
#javascripts_from_config(options = {}) ⇒ Object
3 4 5 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 32 33 34 35 36 37 |
# File 'lib/application_config/view_helpers.rb', line 3 def javascripts_from_config( = {}) html = "" only = [.delete(:only)].flatten.compact.map{|i| i.to_s} if defined?(AppConfig) and AppConfig.javascripts ConfigBuilder.merge_assets(AppConfig.javascripts).each do |javascript| if javascript.is_a? Hash javascript.each do |key, val| next unless only.empty? || only.include?(key.to_s) args = [val].flatten args = args.map{|s| s.gsub("javascripts/", AppConfig.javascript_path)} if AppConfig.javascript_path if defined?(Merb) args << .merge(:bundle => key.to_sym) html << js_include_tag(*args).to_s elsif defined?(Rails) args << .merge(:cache => key.to_s) html << javascript_include_tag(*args).to_s end html << "\n" end else args = [javascript].flatten args = args.map{|s| s.gsub("javascripts/", AppConfig.javascript_path)} if AppConfig.javascript_path args << if defined?(Merb) html << js_include_tag(*args).to_s elsif defined?(Rails) html << javascript_include_tag(*args).to_s end end end end return html end |
#stylesheets_from_config(options = {}) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/application_config/view_helpers.rb', line 39 def stylesheets_from_config( = {}) html = "" only = [.delete(:only)].flatten.compact.map{|i| i.to_s} if defined?(AppConfig) and AppConfig.stylesheets ConfigBuilder.merge_assets(AppConfig.stylesheets).each do |stylesheet| if stylesheet.is_a? Hash stylesheet.each do |key, val| next unless only.empty? || only.include?(key.to_s) args = [val].flatten args = args.map{|s| s.gsub("stylesheets/", AppConfig.stylesheet_path)} if AppConfig.stylesheet_path if defined?(Merb) args << .merge(:bundle => key.to_sym) html << css_include_tag(*args).to_s elsif defined?(Rails) args << .merge(:cache => key.to_s) html << stylesheet_link_tag(*args).to_s end end else args = [stylesheet].flatten args = args.map{|s| s.gsub("stylesheets/", AppConfig.stylesheet_path)} if AppConfig.stylesheet_path args << if defined?(Merb) html << css_include_tag(*args).to_s elsif defined?(Rails) html << stylesheet_link_tag(*args).to_s end end html << "\n" end end return html end |