fanforce-internal-utils 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/fanforce/utils/utils.rb +3 -8
- data/lib/fanforce/utils/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NWM5MDQxZDc2NmI0YjZkYzEzMDJhZjE5MjEzYjg5OWZmYTJiZTY5OA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NDAyY2I1ZDhmNjMyNjgyNWZiNGU5OWY3Mzc4YjA0NjE3ZWIyNDhjZA==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZDkxNTM1ODU0NjA1Njg3Y2QzZDZlZDE1ZmE1YTAwYzVlMmQyZDNjY2EyOGQ4
|
10
|
+
YzgxNzA2OWIzNTI2MWI3MWY4NjgxYzFiMDUxYTZhZjYzOTZiZjJmOTY2NDNk
|
11
|
+
NWJlZDQxOTU5OTlkMDA3ZTgzZDE5ZGYwOTUxNzIzNDg5YTJkYWM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZTc1ZTgyNDIzNzY4YjAyMjkyMjZkZGQ1NDM2YmYwNjFmYWY1ZTFhNjBhYzc5
|
14
|
+
MzY5OWYzNzM0M2RkYWFmODk4NTRlZjk4Mzc2NGI1ZjhiODBjNDY2M2Y0Mzgy
|
15
|
+
NmY4Mjk0MjA2MDkxYjNmZjAyYWFiNTkzMmM0YWI0NGZkZWM1ZGM=
|
data/lib/fanforce/utils/utils.rb
CHANGED
@@ -70,25 +70,20 @@ module Fanforce::Utils
|
|
70
70
|
|
71
71
|
# Creates a string representation of a javascript object for $.tmpl
|
72
72
|
def compile_jquery_tmpls(options={}, &block)
|
73
|
-
begin require 'haml' rescue LoadError raise
|
73
|
+
begin require 'haml' rescue LoadError raise 'You must have the haml gem installed to use Fanforce.compile_jquery_templates.' end
|
74
74
|
context = Object.new
|
75
75
|
class << context
|
76
76
|
include Haml::Helpers
|
77
77
|
end
|
78
78
|
context.init_haml_helpers
|
79
79
|
|
80
|
-
format =
|
80
|
+
format = options[:format] == 'html' ? :html : :json
|
81
81
|
|
82
82
|
return context.capture_haml(&block) if format == :html
|
83
83
|
single_line_html = context.capture_haml(&block).split(/\r?\n/).inject('') {|sl, l| sl += l.strip + ' ' }
|
84
84
|
matches = single_line_html.scan(/<script id=[\"'](.*?)[\"'](?:.*?)>(.*?)(?:<\/script>)/mi)
|
85
85
|
|
86
|
-
|
87
|
-
if format == :jsonp
|
88
|
-
"#{options[:callback]}(#{templates.to_json})"
|
89
|
-
else
|
90
|
-
templates.to_json
|
91
|
-
end
|
86
|
+
matches.inject({}) {|t,m| t[m[0]] = m[1]; t }.to_json
|
92
87
|
end
|
93
88
|
|
94
89
|
end
|