From Sinatra intro :
Templates are evaluated in the same context as route handlers. Instance variables set in route handlers are directly accessible by templates:
get '/:id' do @foo = Foo.find(params[:id]) haml '%h1= @foo.name' end
Or specify an explicit hash of local variables:
get '/:id' do foo = Foo.find(params[:id]) haml '%h1= bar.name', :locals => { :bar => foo } end
This is usually used when rendering templates as partial from other templates.
And for some templates there is (for Radius in this case):
Since you cannot invoke Ruby methods directly from the Radius template, you almost always want to pass locals to it.
source share