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)
What is this init.rb file run, is it a one-time thing or on application load?
Is it simply calling the regiser_template_handler method, on either the ActionView::Template or ActionView:Base class?
How does it work on either one?
It is run once, when the app loads and plugins/gems are loaded in.
Yes. If
ActionView::Templateis defined and responds toregister_template_handlerit will callregister_template_handleron it, otherwise it will call it onActionView::Base.I’m not sure exactly what you mean by this? If you mean why is it like this, it’s for backwards compatibility.
ActionView::Templateis relatively new in rails (introduced around v2.1, I think) so I guess it’s so that it will gracefully fallback when used with older versions.