Require missing libraries and check for defined ActionController constant so ActionView can be used standalone

This commit is contained in:
Joshua Peek
2008-08-26 15:13:28 -05:00
parent 8756dd75b2
commit 9853134b4f
6 changed files with 30 additions and 4 deletions

View File

@@ -1,3 +1,5 @@
require 'set'
module Mime
SET = []
EXTENSION_LOOKUP = Hash.new { |h, k| h[k] = Type.new(k) unless k.blank? }

View File

@@ -1,5 +1,14 @@
require 'action_view/helpers/tag_helper'
require 'html/document'
begin
require 'html/document'
rescue LoadError
html_scanner_path = "#{File.dirname(__FILE__)}/../../action_controller/vendor/html-scanner"
if File.directory?(html_scanner_path)
$:.unshift html_scanner_path
require 'html/document'
end
end
module ActionView
module Helpers #:nodoc:

View File

@@ -1,5 +1,14 @@
require 'action_view/helpers/tag_helper'
require 'html/document'
begin
require 'html/document'
rescue LoadError
html_scanner_path = "#{File.dirname(__FILE__)}/../../action_controller/vendor/html-scanner"
if File.directory?(html_scanner_path)
$:.unshift html_scanner_path
require 'html/document'
end
end
module ActionView
module Helpers #:nodoc:

View File

@@ -72,7 +72,7 @@ module ActionView
end_src
begin
logger = Base.logger
logger = defined? ActionController && Base.logger
logger.debug "Compiling template #{render_symbol}" if logger
ActionView::Base::CompiledTemplates.module_eval(source, filename, 0)

View File

@@ -16,7 +16,11 @@ module ActionView
memoize :counter_name
def render(view, local_assigns = {})
ActionController::Base.benchmark("Rendered #{path_without_format_and_extension}", Logger::DEBUG, false) do
if defined? ActionController
ActionController::Base.benchmark("Rendered #{path_without_format_and_extension}", Logger::DEBUG, false) do
super
end
else
super
end
end

View File

@@ -1,3 +1,5 @@
require 'action_controller/mime_type'
module ActionView #:nodoc:
class Template
extend TemplateHandlers