Sha256: 8741e4c4723dccc498feac82e178a1f1f5e34b900e46071650f6b0162d137f26

Contents?: true

Size: 1.05 KB

Versions: 2

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}'>"
            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

2 entries across 2 versions & 1 rubygems

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