Note that there are some explanatory texts on larger screens.

plurals
  1. POMy partials doesn't working
    primarykey
    data
    text
    <p>I am trying to split my HAML view to the separate files. I have read the <a href="http://sinatra-book.gittr.com/#implementation_of_rails_style_partials" rel="nofollow">Sinatra Book</a> and tried to implement the basic version.</p> <p>So I have created <strong>app_helpers.rb</strong> file:</p> <pre><code># Usage: partial :foo helpers do def partial(page, options={}) haml page, options.merge!(:layout =&gt; false) end end </code></pre> <p>And require it in my <strong>application.rb</strong>:</p> <pre><code>require 'sinatra' require_relative './app_helpers.rb' </code></pre> <p>Then I have created partial views/test.haml:</p> <pre><code>&lt;h3&gt; Test message &lt;/h3&gt; </code></pre> <p>And require it in my <strong>index.haml</strong>:</p> <pre><code>= partial :test </code></pre> <p>But when I refresh my page I get the error message:</p> <pre><code>NoMethodError - undefined method `partial' for #&lt;Application:0x514dbe0&gt;: c:/Dropbox/development/myprojects/test/sinatra-bootstrap/views/index.haml:27:in `evaluate_source' C:/Ruby193/lib/ruby/gems/1.9.1/gems/tilt-1.3.3/lib/tilt/template.rb:209:in `instance_eval' C:/Ruby193/lib/ruby/gems/1.9.1/gems/tilt-1.3.3/lib/tilt/template.rb:209:in `evaluate_source' C:/Ruby193/lib/ruby/gems/1.9.1/gems/tilt-1.3.3/lib/tilt/template.rb:144:in `cached_evaluate' C:/Ruby193/lib/ruby/gems/1.9.1/gems/tilt-1.3.3/lib/tilt/template.rb:127:in `evaluate' C:/Ruby193/lib/ruby/gems/1.9.1/gems/tilt-1.3.3/lib/tilt/haml.rb:24:in `evaluate' C:/Ruby193/lib/ruby/gems/1.9.1/gems/tilt-1.3.3/lib/tilt/template.rb:76:in `render' C:/Ruby193/lib/ruby/gems/1.9.1/gems/sinatra-1.3.1/lib/sinatra/base.rb:625:in `render' C:/Ruby193/lib/ruby/gems/1.9.1/gems/sinatra-1.3.1/lib/sinatra/base.rb:522:in `haml' </code></pre> <p>How can I fix it?</p> <p><strong>Updated:</strong></p> <p>All works fine if I rewrite <strong>app_helpers.rb</strong> such way:</p> <pre><code>def partial(page, options={}) haml page, options.merge!(:layout =&gt; false) end </code></pre> <p>What is the reason of this?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload