File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change 22
33class JPbuilderHandler
44 cattr_accessor :default_format , :default_callback
5- self . default_format = Mime [ :json ]
6- self . default_callback = nil
75
8- def self . call ( template )
6+ def initialize
7+ self . default_callback = nil
8+ self . default_format = ( Rails . version < '6.0.0' ) ? Mime [ :json ] : :json
9+ end
10+
11+ def self . call ( template , source = nil )
12+ source ||= template . source
913 %{
1014 if defined?(json)
11- #{ template . source }
15+ #{ source }
1216 else
1317 result = JbuilderTemplate.encode(self) do |json|
14- #{ template . source }
18+ #{ source }
1519 end
20+ result = result.each_char.to_a.map { |chr| chr.ord > 1000 ? "\\ \\ u\# {"%4.4x" % chr.ord}" : chr }.join
1621 callback = params[:callback] || JPbuilderHandler.default_callback
1722 if callback.present?
1823 "/**/\# {callback}(\# {result});"
You can’t perform that action at this time.
0 commit comments