Module: Sprangular::ApplicationHelper
- Defined in:
- app/helpers/sprangular/application_helper.rb
Instance Method Summary collapse
- #cached_templates ⇒ Object
- #cached_templates_for_dir(files, dir) ⇒ Object
- #js_environment ⇒ Object
- #payment_methods ⇒ Object
Instance Method Details
#cached_templates ⇒ Object
39 40 41 42 43 |
# File 'app/helpers/sprangular/application_helper.rb', line 39 def cached_templates Sprangular::Engine.config.cached_paths.inject({}) do |files, dir| cached_templates_for_dir(files, dir) end end |
#cached_templates_for_dir(files, dir) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'app/helpers/sprangular/application_helper.rb', line 45 def cached_templates_for_dir(files, dir) root = Sprangular::Engine.root files = Dir[root + "app/assets/templates/#{dir}/**"].inject(files) do |hash, path| asset_path = asset_path path.gsub(root.to_s + "/app/assets/templates/", "") local_path = 'app/assets/templates/' + asset_path hash[asset_path.gsub(/.slim$/, '')] = Tilt.new(path).render.html_safe if !File.exists?(local_path) hash end Dir["app/assets/templates/#{dir}/**"].inject(files) do |hash, path| sprockets_path = path.gsub("app/assets/templates/", "") asset_path = asset_path(sprockets_path). gsub(/^\/app\/assets\/templates/, '/assets'). gsub(/.slim$/, '') hash[asset_path] = Rails.application.assets.find_asset(sprockets_path).body.html_safe hash end end |
#js_environment ⇒ Object
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 'app/helpers/sprangular/application_helper.rb', line 12 def js_environment config = ::Spree::Config store = Spree::Store.current templates = Hash[ Rails.application.assets.each_logical_path. select { |file| file.end_with?('html') }. map do |file| path = digest_assets? ? File.join('/assets', Rails.application.assets[file].digest_path) : asset_path(file) [file, path] end ] {env: Rails.env, config: { site_name: store.seo_title || store.name, logo: asset_path(config.logo), default_country_id: config.default_country_id, facebook_app_id: ENV['FACEBOOK_APP_ID'], payment_methods: payment_methods, image_sizes: Spree::Image.[:attachment][:styles].keys, product_page_size: Spree::Config.products_per_page }, templates: templates } end |
#payment_methods ⇒ Object
3 4 5 6 7 8 9 10 |
# File 'app/helpers/sprangular/application_helper.rb', line 3 def payment_methods Spree::PaymentMethod.available(:front_end).map do |method| { id: method.id, name: method.name } end end |