title: Rails helper for Haml
body: <p>I have a bit of HAML code that gets repeated in something like 10 views and would like to put it into a helper of some kind. Doing a search here produced some interesting results but ultimately no answers, so:</p>
  
  <p>In <code>application_helper.rb</code> I have this:</p>
  
  <pre><code>def pagination_helper(object)
    haml_tag :div, :class =&gt; 'apple_pagination page_info' do
      page_entries_info @book_formats
      paginate @book_formats
    end
  end
  </code></pre>
  
  <p>In the view template I have this: </p>
  
  <pre><code>- pagination_helper(@book_formats)
  </code></pre>
  
  <p>If I try calling it with <code>=</code> to output something I get an error.</p>
  
  <p>The above will not give me an error but it won't call the methods either. I get empty divs. </p>
  
  <p>Ultimately the code I want to repeat is this:</p>
  
  <pre><code>.apple_pagination.page_info
    = page_entries_info @book_formats
    = paginate @book_formats
  </code></pre>
  
  <p>The code would be the same except the <code>object</code> would change and I send that from the view template. For example <code>@book_formats</code> would change to <code>@dvds</code>, etc. </p>