Browse files

Require missing libraries and check for defined ActionController cons…

…tant so ActionView can be used standalone
  • Loading branch information...
1 parent 8756dd7 commit 9853134b4fec468962260f0e713d2f87046eb8b3 @josh josh committed Aug 26, 2008
View
2 actionpack/lib/action_controller/mime_type.rb
@@ -1,3 +1,5 @@
+require 'set'
+
module Mime
SET = []
EXTENSION_LOOKUP = Hash.new { |h, k| h[k] = Type.new(k) unless k.blank? }
View
11 actionpack/lib/action_view/helpers/sanitize_helper.rb
@@ -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
11 actionpack/lib/action_view/helpers/text_helper.rb
@@ -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
2 actionpack/lib/action_view/renderable.rb
@@ -72,7 +72,7 @@ def #{render_symbol}(local_assigns)
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
6 actionpack/lib/action_view/renderable_partial.rb
@@ -16,7 +16,11 @@ def counter_name
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
2 actionpack/lib/action_view/template.rb
@@ -1,3 +1,5 @@
+require 'action_controller/mime_type'
+
module ActionView #:nodoc:
class Template
extend TemplateHandlers

0 comments on commit 9853134

Please sign in to comment.