lib/fanforce/api/utils.rb in fanforce-0.6.1 vs lib/fanforce/api/utils.rb in fanforce-0.6.2

- old
+ new

@@ -63,39 +63,6 @@ def remove_sensitive_params(params) params.clone.delete_if { |k,v| [:api_key].include? k } end - def log(str) - #puts "Fanforce: #{str}" - end - - def decode_json(str, symbolize_keys=true) - log str - MultiJson.load(str, :symbolize_keys => symbolize_keys) - end - - # Creates a string representation of a javascript object for $.tmpl - def compile_jquery_tmpls(options={}, &block) - begin require 'haml' rescue LoadError raise "You must have the haml gem installed for Fanforce.compile_jquery_templates to work." end - context = Object.new - class << context - include Haml::Helpers - end - context.init_haml_helpers - - format = if options[:format] == 'html' then :html else options[:callback].present? ? :jsonp : :json end - - return context.capture_haml(&block) if format == :html - single_line_html = context.capture_haml(&block).split(/\r?\n/).inject('') {|sl, l| sl += l.strip + ' ' } - matches = single_line_html.scan(/<script id=[\"'](.*?)[\"'](?:.*?)>(.*?)(?:<\/script>)/mi) - - templates = matches.inject({}) {|t,m| t[m[0]] = m[1]; t } - if format == :jsonp - "#{options[:callback]}(#{templates.to_json})" - else - templates.to_json - end - end - - end