title: Layout paths not working in Sinatra
body: <p>Using Sinatra for the web framework and HAML for the pages, I have a layout file at <code>/views/layout.haml</code>. I also have javascript and css files in <code>/public</code>. Within the layout scripts and css are defined similar to this:</p>
  
  <pre><code>%script{:type =&gt; "text/javascript", :src =&gt; "test.js"}
  %link{:rel =&gt; "stylesheet", :type =&gt; "text/css", :href =&gt; "test.css"}
  </code></pre>
  
  <p>When I have a basic route defined in Sinatra everything works fine:</p>
  
  <pre><code>get '/' do
    haml :index
  end
  </code></pre>
  
  <p>But when the route has multiple parts, such as '/route/1', suddenly the paths to <code>test.js</code> and <code>test.css</code> no longer work. The haml file loads properly, but the paths in the layout are no longer valid.</p>
  
  <p>After experimenting some, if I change the paths to something like <code>"//public/test.js"</code>, instead of just <code>"test.js"</code>, it again loads... but only for the route <code>/route/1</code>. Unfortunately the first route <code>/</code> no longer loads.</p>
  
  <p>How is this typically handled in Sinatra with routes like this?</p>