Named Templates

Templates may also be defined using the top-level template method:

template :layout do
  "%html\n  =yield\n"
end

template :index do
  '%div.title Hello World!'
end

get '/' do
  haml :index
end
If a template named layout exists, it will be used each time a template is rendered.

You can individually disable layouts by passing :layout => false or disable them by default via set :haml, :layout => false:

get '/' do
  haml :index, :layout => !request.xhr?
end



Casiano Rodriguez León 2015-01-07