Class: Template::Handlers::JSONBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/json_builder/template.rb

Class Method Summary collapse

Class Method Details

.call(template) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/json_builder/template.rb', line 41

def self.call(template)
  source = if template.source.empty?
    File.read(template.identifier)
  else # use source
    template.source
  end

  %{
    ::JSONBuilder::Compiler.generate(:scope => self, :pretty => ActionView::Base.pretty_print_json, :callback => ActionView::Base.json_callback) {
      #{source}
    }
  }
end