Sha256: 599a9a09a1f70b460e78d888043a1ff3d1e292165c87c29cf66e18d291750f9c

Contents?: true

Size: 1.05 KB

Versions: 1

Compression:

Stored size: 1.05 KB

Contents

require "#{File.dirname(__FILE__)}/log_note"

module Footnotes
  module Notes
    class PartialsNote <  LogNote
      def initialize(controller)
        @controller = controller
        @template = controller.instance_variable_get('@template')
        @partials = get_partials
      end
      
      def content
        result = '<ul>'
          @partials.collect.each do |partial|
            full_filename = File.join(File.expand_path(RAILS_ROOT), 'app', 'views', partial.first.to_s)
            result += "<li><a href='#{Footnotes::Filter.prefix(full_filename, 1, 1)}'>"
            result += "#{partial.last}</a></li>"
          end
        result += '</ul>'
       
       result
      end
      
      def title
        "Partials (#{@partials.length})"        
      end
      
      private
      def get_partials
        partials = escape(log_tail).scan(/Rendered.*\(/).collect{|x| x.gsub('Rendered ', '').gsub('(', '').strip}.uniq
        partials[0..partials.length].collect{|partial| [@template.send(:_pick_template, partial), partial]}
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ceritium-rails-footnotes-3.4.1.1 lib/rails-footnotes/notes/partials_note.rb