What are you trying works in rails
! Sinatra
has no partial
method. An implementation of partial
on Sinatra
looks like this (source gist) from github:
module Haml
module Helpers
def partial(template, *args)
template_array = template.to_s.split('/')
template = template_array[0..-2].join('/') + "/_#{template_array[-1]}"
options = args.last.is_a?(Hash) ? args.pop : {}
options.merge!(:layout => false)
if collection = options.delete(:collection) then
collection.inject([]) do |buffer, member|
buffer << haml(:"#{template}", options.merge(:layout =>
false, :locals => {template_array[-1].to_sym => member}))
end.join("\n")
else
haml(:"#{template}", options)
end
end
end
end
Including this method, you may call partial
in your .haml
files, like
= partial("partial_name")
If you want to render
a view in an other view syntax is
= render(:haml,:'rel_path_to_view',:locals => {:optional => option})
Notice the syntax differences between rails
and sinatra
regarding render
method!