lib/mojito/rendering/content.rb in mojito-0.1.1 vs lib/mojito/rendering/content.rb in mojito-0.1.2
- old
+ new
@@ -6,8 +6,19 @@
def write(content)
response.write content
end
+ def render_as(type, content, *args)
+ renderer = "to_#{type}".to_sym
+ if content.respond_to? renderer
+ response.write(content.send(renderer, *args[0...content.method(renderer).arity]))
+ else
+ Mojito::Rendering::StatusCodes.instance_method(:not_found!).bind(self).call
+ end
+ end
+
end
+ Mojito::PLUGINS[:content] = Content
+
end
\ No newline at end of file