class ApplicationController < ActionController::Base

  def render_liquid_template(options={})    
    controller = options[:controller].to_s if options[:controller]
    controller ||= request.symbolized_path_parameters[:controller]
    
    action = options[:action].to_s if options[:action]    
      action ||= request.symbolized_path_parameters[:action]
    
      locals = options[:locals] || {}  
      locals.each_pair do |var, obj| 
          assigns[var.to_s] = \
                    obj.respond_to?(:to_liquid) ? obj.to_liquid : obj 
      end
  
      path = "#{RAILS_ROOT}/app/views/#{controller}/#{action}.liquid"
      contents = File.read(Pathname.new(path).cleanpath)
    
    template = Liquid::Template.parse(contents)                
    returning template.render(assigns, :registers => {:controller => controller}) do |result|
      yield template, result if block_given?
    end
  end

end