Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Haml files not counted in Partials note #83

Closed
paulfioravanti opened this Issue Oct 23, 2012 · 10 comments

Comments

Projects
None yet
4 participants

Haml templates in my Rails 3 apps don't seem to be recognized by the Partials note. The partials count is always zero, and none of them are displayed when I click the Partials link in the notes. I get expected output with ERb templates.

I've tested so far on two different new Rails 3 apps with Haml templates, all located under the expected app/views directory. Am I missing something in the configuration?

Until an official fix is made, I was able to solve this problem using a monkey patch outlined in a StackOverflow thread here.

Contributor

westonplatter commented Dec 21, 2012

I was able to see all Haml partials with default configs (as described in readme).

Are you still have this problem?

Still having the problem on version 3.7.9.

If I use default configuration below, as per the Readme, whenever I use Haml for my views, the Partials footnote is always zero (ERb template footnotes display as expected):

config/initializers/rails_footnotes.rb

if defined?(Footnotes) && Rails.env.development?
  Footnotes.run! # first of all

  # ... other init code
  Footnotes::Filter.prefix = 'subl://open?url=file://%s&line=%d&column=%d'
end

I commented out the Footnotes::Filter.prefix ... line in the original config to check it that was the issue for some reason, but the Partials count was still zero.

If I add the patch to the config, both Haml and ERb Partials notes display as expected:

if defined?(Footnotes) && Rails.env.development?
  Footnotes.run! # first of all
  Footnotes::Notes::LogNote::LoggingExtensions.module_eval do
    def add(*args, &block)
      super
      logged_message = args[2] + "\n"
      Footnotes::Notes::LogNote.log(logged_message)
      logged_message
    end
  end

  # ... other init code
  Footnotes::Filter.prefix = 'subl://open?url=file://%s&line=%d&column=%d'
end
Contributor

westonplatter commented Dec 22, 2012

tried this out on a brand new rails 3.2.9 app, and did not see Haml partials as you described. Not sure why, but it's an issue. Any ideas why?

From the answer that helped me on StackOverflow:

"Looking at the rails-footnotes code (version 3.7.9), it looked to me like the problem is in this method:

module Footnotes
  module Notes
    class LogNote < AbstractNote
      ...
      module LoggingExtensions
        def add(*args, &block)
          logged_message = super
          Footnotes::Notes::LogNote.log(logged_message)
          logged_message
        end
      end
      ...
    end
  end
end

The add method is assuming that super returns the message that is being logged, but in my testing super was returning a boolean value."

jmuheim commented Mar 11, 2014

This seems to work partly also for SLIM partials, but not 100%. I have the following structure:

# show.html.slim
= render `vocabularies`, vocabularies: @vocabularies

# _vocabularies.html.haml
= render vocabularies

# _vocabulary.html.haml
= vocabulary.name

Rails footnotes now only displays the _vocabulary partial:

image

Collaborator

Intrepidd commented Mar 11, 2014

Thanks for the infos, I'm currently refactoring this gem and planning a release, with support for recent ruby / rails + fixing all the known bugs, I'll work on that soon

jmuheim commented Mar 11, 2014

Thank you! 👍

After re-installing Rails Footnotes 4.0.1 on a Rails 4.1.1 app, Haml partials are counted correctly, so I'm closing this issue. Thanks very much for the improvements to this gem!

Collaborator

Intrepidd commented Jun 8, 2014

Glad I could help!

Adrien Siami

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment