Sinatra HAML Heroku in-file templates
I'm following a tutorial from http://ruby.about.com/od/sinatra/a/sinatra7_2.htm however I'm having a few problems running the app within my own environment.
The problem is that the following line:
haml :list, :locals => { :cs => Contact.all }
results in a "No such file or directory - [...]/views/list.haml"
The HAML template is within the file, and terminated by:
__END__
@@ layout
however ruby seems to be looking in the views/ directory for the Haml files.
Is this tutorial missing a call to force ruby to loo开发者_运维百科k inside the file, or this resource suggests that in-file templates are broken for version 1.9.2.
I'm using sinatra version 1.1.2 and ruby 1.8.7.
I can't reproduce with Sinatra 1.1.2 and Ruby 1.9.2.
So something like this (sinatrarb.com) example generates the error?
require 'sinatra'
get '/' do
haml :index
end
__END__
@@ layout
%html
= yield
@@ index
%div.title Hello world!!!!!
calling a list template you will also need add it to the end of your file:
require 'sinatra'
get '/' do
haml :list
end
__END__
@@ layout
%html
= yield
@@ list
%div.title the LIST
精彩评论