Permalink
Browse files

support JSON-P callback parameter

  • Loading branch information...
davidhq committed Dec 20, 2009
1 parent 089d31d commit ac6e926405e153d764e2eb4861cef5e18eea1a1b
Showing with 8 additions and 2 deletions.
  1. +8 −2 lib/asbestos.rb
View
@@ -30,8 +30,14 @@ def #{compiled_name}
end
render :text => @template.with_template(template) {
- @template.send(:_evaluate_assigns_and_ivars)
- @template.send(compiled_name)
+ @template.send(:_evaluate_assigns_and_ivars)
+ result = @template.send(compiled_name)
+ # support JSON-P
+ if callback = options[:callback]
+ "#{callback}(#{result})"
+ else
+ result
+ end
}
end
end

0 comments on commit ac6e926

Please sign in to comment.