lib/goliath/rack/templates.rb in goliath-0.9.4 vs lib/goliath/rack/templates.rb in goliath-1.0.0.beta.1
- old
+ new
@@ -319,17 +319,28 @@
NullLayout
else
Tilt.new(layout_filename, nil, options)
end
- template_filename = find_template(views, data, engine)
- unless template_filename
- raise Goliath::Validation::InternalServerError, "Template #{data} not found in #{views} for #{engine}"
- end
+ # mimic sinatra behavior, if a string is given consider it as a template source
+ # otherwise a symbol is expected to be a template path
+ if data.is_a?(Symbol)
+ template_filename = find_template(views, data, engine)
+ unless template_filename
+ raise Goliath::Validation::InternalServerError, "Template #{data} not found in #{views} for #{engine}"
+ end
- template = Tilt.new(template_filename, nil, options)
- output = layout_template.render(scope, locals) do
- template.render(scope, locals)
+ template = Tilt.new(template_filename, nil, options)
+ output = layout_template.render(scope, locals) do
+ template.render(scope, locals)
+ end
+
+ else
+ template = Tilt[engine].new(nil, nil, options){ data }
+ output = layout_template.render(scope, locals) do
+ template.render(scope, locals)
+ end
+
end
output.extend(ContentTyped).content_type = content_type if content_type
output
end