method

_pick_template

rails latest stable - Class: ActionView::Base

Method deprecated or moved

This method is deprecated or moved on the latest stable version. The last existing version (v2.2.1) is shown here.

_pick_template(template_path)
private

No documentation available.

# File actionpack/lib/action_view/base.rb, line 305
      def _pick_template(template_path)
        return template_path if template_path.respond_to?(:render)

        path = template_path.sub(/^\//, '')
        if m = path.match(/(.*)\.(\w+)$/)
          template_file_name, template_file_extension = m[1], m[2]
        else
          template_file_name = path
        end

        # OPTIMIZE: Checks to lookup template in view path
        if template = self.view_paths["#{template_file_name}.#{template_format}"]
          template
        elsif template = self.view_paths[template_file_name]
          template
        elsif @_render_stack.first && template = self.view_paths["#{template_file_name}.#{@_render_stack.first.format_and_extension}"]
          template
        elsif template_format == :js && template = self.view_paths["#{template_file_name}.html"]
          @template_format = :html
          template
        else
          template = Template.new(template_path, view_paths)

          if self.class.warn_cache_misses && logger
            logger.debug "[PERFORMANCE] Rendering a template that was " +
              "not found in view path. Templates outside the view path are " +
              "not cached and result in expensive disk operations. Move this " +
              "file into #{view_paths.join(':')} or add the folder to your " +
              "view path list"
          end

          template
        end
      end