Sha256: 82ef72fb6f7de858c8bcf413f8e9d662a9dcd7f1e7aecd9a7a123354f4e5544c
Contents?: true
Size: 1.31 KB
Versions: 19
Compression:
Stored size: 1.31 KB
Contents
require 'action_view' class ActionView::TemplateRenderer def render(context, options) @view = context @details = extract_details(options) template = get_template_by_user_agent(context, options) context = @lookup_context prepend_formats(template.formats) unless context.rendered_format context.rendered_format = template.formats.first || formats.first end render_template(template, options[:layout], options[:locals]) end private def get_user_agent(context) if context.respond_to?(:user_agent) if context.respond_to?(:controller) if context.controller.respond_to?(:session) context.user_agent end end end end def get_template_by_user_agent(context, options) ret = nil option_for_template = options[:template] ua = get_user_agent(context) if ua ua.priorities.each do |priority| begin options[:template] = option_for_template + '.' + priority ret = determine_template(options) break rescue ActionView::MissingTemplate end end end unless ret options[:template] = option_for_template ret = determine_template(options) end Rails.logger.debug "UserAgent: #{ua ? ua.name : 'unknown'} => #{ret.identifier}" ret end end
Version data entries
19 entries across 19 versions & 1 rubygems