diff --git a/History.md b/History.md index 9083759..266dbb8 100644 --- a/History.md +++ b/History.md @@ -3,6 +3,7 @@ ## 3.0.0 / not yet released / branch "master" * ... +* Remove ActionView template handler [Dylan Thacker-Smith, dylanahsmith] * Freeze lots of string literals for new Ruby 2.1 optimization, see #297 [Florian Weingarten, fw42] * Allow newlines in tags and variables, see #324 [Dylan Thacker-Smith, dylanahsmith] * Tag#parse is called after initialize, which now takes options instead of tokens as the 3rd argument. See #321 [Dylan Thacker-Smith, dylanahsmith] diff --git a/init.rb b/init.rb deleted file mode 100644 index 5ef3c07..0000000 --- a/init.rb +++ /dev/null @@ -1,8 +0,0 @@ -require 'liquid' -require 'extras/liquid_view' - -if defined? ActionView::Template and ActionView::Template.respond_to? :register_template_handler - ActionView::Template -else - ActionView::Base -end.register_template_handler(:liquid, LiquidView) diff --git a/lib/extras/liquid_view.rb b/lib/extras/liquid_view.rb deleted file mode 100644 index 843a539..0000000 --- a/lib/extras/liquid_view.rb +++ /dev/null @@ -1,51 +0,0 @@ -# LiquidView is a action view extension class. You can register it with rails -# and use liquid as an template system for .liquid files -# -# Example -# -# ActionView::Base::register_template_handler :liquid, LiquidView -class LiquidView - PROTECTED_ASSIGNS = %w( template_root response _session template_class action_name request_origin session template - _response url _request _cookies variables_added _flash params _headers request cookies - ignore_missing_templates flash _params logger before_filter_chain_aborted headers ) - PROTECTED_INSTANCE_VARIABLES = %w( @_request @controller @_first_render @_memoized__pick_template @view_paths - @helpers @assigns_added @template @_render_stack @template_format @assigns ) - - def self.call(template) - "LiquidView.new(self).render(template, local_assigns)" - end - - def initialize(view) - @view = view - end - - def render(template, local_assigns = nil) - @view.controller.headers["Content-Type"] ||= 'text/html; charset=utf-8' - - # Rails 2.2 Template has source, but not locals - if template.respond_to?(:source) && !template.respond_to?(:locals) - assigns = (@view.instance_variables - PROTECTED_INSTANCE_VARIABLES).inject({}) do |hash, ivar| - hash[ivar[1..-1]] = @view.instance_variable_get(ivar) - hash - end - else - assigns = @view.assigns.reject{ |k,v| PROTECTED_ASSIGNS.include?(k) } - end - - source = template.respond_to?(:source) ? template.source : template - local_assigns = (template.respond_to?(:locals) ? template.locals : local_assigns) || {} - - if content_for_layout = @view.instance_variable_get("@content_for_layout") - assigns['content_for_layout'] = content_for_layout - end - assigns.merge!(local_assigns.stringify_keys) - - liquid = Liquid::Template.parse(source) - liquid.render(assigns, :filters => [@view.controller.master_helper_module], :registers => {:action_view => @view, :controller => @view.controller}) - end - - def compilable? - false - end - -end