Sha256: 8acea7db7ca6d41fed9cc9bffa14ff5a74a48745794128d287338d413484e065

Contents?: true

Size: 759 Bytes

Versions: 4

Compression:

Stored size: 759 Bytes

Contents

require 'jpmobile/lookup_context'

module Jpmobile
  module FallbackViewSelector
    def render_to_body(options)
      if Jpmobile.config.fallback_view_selector &&
         lookup_context.mobile.present? && !lookup_context.mobile.empty?
        begin
          expected_view_file = lookup_context.find_template(options[:template], options[:prefixes])

          _candidates = lookup_context.mobile.filter_map do |variant|
            target_template = options[:template] + '_' + variant
            expected_view_file.virtual_path.match(target_template)
          end

          if _candidates.empty?
            lookup_context.mobile = []
          end
        rescue ActionView::MissingTemplate
        end
      end

      super(options)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
jpmobile-7.1.0 lib/jpmobile/fallback_view_selector.rb
jpmobile-7.0.4 lib/jpmobile/fallback_view_selector.rb
jpmobile-7.0.3 lib/jpmobile/fallback_view_selector.rb
jpmobile-7.0.2 lib/jpmobile/fallback_view_selector.rb