Chris Lambert
2005-Aug-24 05:47 UTC
Determine if layout was rendered from within a filter?
Hi,
I''ve got a filter setup in ApplicationController that tidies up any
HTML output from Rails, mostly from my templates. However, I only want
the output to be "tidied" if a layout is rendered for the action.
Otherwise, tidy will attempt to clean up AJAX responses (including
those that are automaticaly generated, i.e. auto_complete_for) which
aren''t HTML to begin with.
class ApplicationController < ActionController::Base
after_filter :tidy
def tidy
response.body = Tidy.new(
:output_xhtml => true,
:wrap => 100,
:quiet => true,
:indent => ''yes'').clean(response.body)
end
end
I want to do something like:
def tidy
return if rendered_layout.nil?
response.body = Tidy.new(...).clean(response.body)
end
After searching through the API and code for an hour, I can''t find any
such method. Any help?
Thanks!
--
Chris Lambert <chris.lambert-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>