jsontoerb 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +1 -0
- data/Gemfile.lock +10 -0
- data/jsontoerb.gemspec +1 -1
- data/lib/jsontoerb.rb +4 -1
- data/spec/jsontoerb_spec.rb +5 -0
- metadata +2 -2
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,15 +1,22 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
+
POpen4 (0.1.4)
|
5
|
+
Platform (>= 0.4.0)
|
6
|
+
open4
|
7
|
+
Platform (0.4.0)
|
4
8
|
diff-lcs (1.1.3)
|
5
9
|
erubis (2.7.0)
|
6
10
|
git (1.2.5)
|
11
|
+
htmlcompressor (0.0.5)
|
12
|
+
yui-compressor (~> 0.9.6)
|
7
13
|
jeweler (1.8.4)
|
8
14
|
bundler (~> 1.0)
|
9
15
|
git (>= 1.2.5)
|
10
16
|
rake
|
11
17
|
rdoc
|
12
18
|
json (1.7.4)
|
19
|
+
open4 (1.3.0)
|
13
20
|
rake (0.9.2.2)
|
14
21
|
rdoc (3.12)
|
15
22
|
json (~> 1.4)
|
@@ -21,6 +28,8 @@ GEM
|
|
21
28
|
rspec-expectations (2.8.0)
|
22
29
|
diff-lcs (~> 1.1.2)
|
23
30
|
rspec-mocks (2.8.0)
|
31
|
+
yui-compressor (0.9.6)
|
32
|
+
POpen4 (>= 0.1.4)
|
24
33
|
|
25
34
|
PLATFORMS
|
26
35
|
ruby
|
@@ -28,6 +37,7 @@ PLATFORMS
|
|
28
37
|
DEPENDENCIES
|
29
38
|
bundler (~> 1.2.0)
|
30
39
|
erubis
|
40
|
+
htmlcompressor
|
31
41
|
jeweler (~> 1.8.4)
|
32
42
|
json
|
33
43
|
rdoc (~> 3.12)
|
data/jsontoerb.gemspec
CHANGED
data/lib/jsontoerb.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'erubis'
|
2
2
|
require 'json'
|
3
|
+
require 'htmlcompressor'
|
3
4
|
|
4
5
|
class JsonToErb
|
5
6
|
|
@@ -7,7 +8,9 @@ class JsonToErb
|
|
7
8
|
template = Erubis::Eruby.new(template_content)
|
8
9
|
params = JSON.parse(json_string)
|
9
10
|
css = lambda {|css_class| css_map[css_class] || css_class }
|
10
|
-
|
11
|
+
html = template.result({:params => params, :css => css})
|
12
|
+
compressor = HtmlCompressor::Compressor.new(:remove_intertag_spaces => true)
|
13
|
+
return compressor.compress(html)
|
11
14
|
end
|
12
15
|
|
13
16
|
end
|
data/spec/jsontoerb_spec.rb
CHANGED
@@ -14,4 +14,9 @@ describe "Jsontoerb" do
|
|
14
14
|
JsonToErb.render_template(template, "{\"name\": \"Name\"}", {"cssClass" => "a"}).should == "<div class='a'>Name</div>"
|
15
15
|
end
|
16
16
|
|
17
|
+
it "should be compressed with htmlcompressor" do
|
18
|
+
template = "<div ><%= params['name'] %></div> <div></div>"
|
19
|
+
JsonToErb.render_template(template, "{\"name\": \"Name\"}").should == "<div>Name</div><div></div>"
|
20
|
+
end
|
21
|
+
|
17
22
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jsontoerb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -118,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
118
118
|
version: '0'
|
119
119
|
requirements: []
|
120
120
|
rubyforge_project:
|
121
|
-
rubygems_version: 1.8.
|
121
|
+
rubygems_version: 1.8.24
|
122
122
|
signing_key:
|
123
123
|
specification_version: 3
|
124
124
|
summary: Gem to render erb template using json data
|