herbie 0.3.3 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/herbie/erb_helpers.rb +1 -1
- data/lib/herbie/generic_helpers.rb +1 -1
- data/lib/herbie/html_helpers.rb +4 -18
- data/lib/herbie.rb +2 -2
- data/spec/herbie_spec.rb +16 -29
- data/spec/spec.opts +1 -1
- metadata +20 -31
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a0058611b546601d33f5fee0834dad01f4fe7bcc
|
4
|
+
data.tar.gz: 9db7133fba1303205008ca5b506ed9c45f358a55
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2515e779fa85aeab77fb9c8573e9c858a4cf9fbc3e5a89b88571a1ea8e47695f4e5fd7a4545e862b3dc37f40eb7d08bfb8a549d06a083da2603e42e19d8f588e
|
7
|
+
data.tar.gz: df17b5938a902da78b75cf00aa18620c08315e39f6bf71d9c64d140ec657b0cc3b28196a4d2b27219b5c85a3cc63c955234f7a79509fe8f85a15d14f10c13263
|
data/lib/herbie/erb_helpers.rb
CHANGED
data/lib/herbie/html_helpers.rb
CHANGED
@@ -13,7 +13,7 @@ module Herbie
|
|
13
13
|
end
|
14
14
|
else
|
15
15
|
case name
|
16
|
-
when :select
|
16
|
+
when :select
|
17
17
|
option_tags = attrs.delete(:options).collect do |option|
|
18
18
|
if option.key? :label
|
19
19
|
option[:content] = option.delete(:options).collect {|o| tag :option, o}.join
|
@@ -82,12 +82,12 @@ module Herbie
|
|
82
82
|
erb_concat "#{tag :style, default_attrs.merge(attrs)}\n#{capture_erb(&block)}\n</style>\n"
|
83
83
|
else
|
84
84
|
href = "/stylesheets/#{href}" unless href.match(/^\/{1,2}|^http:\/\/|^https:\/\//)
|
85
|
-
|
85
|
+
|
86
86
|
if attrs[:minified]
|
87
87
|
attrs.delete :minified
|
88
88
|
href = href.sub(/.css$/, '.min.css') if href && !href.match(/.min.css$/)
|
89
89
|
end
|
90
|
-
|
90
|
+
|
91
91
|
attrs = default_attrs.merge({:href => href}.merge(attrs))
|
92
92
|
"#{tag :link, attrs}"
|
93
93
|
end
|
@@ -102,19 +102,5 @@ module Herbie
|
|
102
102
|
end
|
103
103
|
end
|
104
104
|
|
105
|
-
def content_for(name, content=nil, &block)
|
106
|
-
@captured_content ||= {}
|
107
|
-
|
108
|
-
if content || block_given?
|
109
|
-
if @captured_content.key? name
|
110
|
-
@capured_content[name] += content || capture_erb(&block)
|
111
|
-
else
|
112
|
-
@capured_content[name] = content || capture_erb(&block)
|
113
|
-
end
|
114
|
-
else
|
115
|
-
@captured_content[name]
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
105
|
end
|
120
|
-
end
|
106
|
+
end
|
data/lib/herbie.rb
CHANGED
data/spec/herbie_spec.rb
CHANGED
@@ -38,37 +38,37 @@ describe Herbie::Helpers do
|
|
38
38
|
|
39
39
|
tag(:input, attrs).should == "<input type=\"#{attrs[:type]}\" name=\"#{attrs[:name]}\" value=\"#{attrs[:value]}\" checked>"
|
40
40
|
end
|
41
|
-
|
41
|
+
|
42
42
|
it "should output the content parameter as an attribute on meta tags" do
|
43
43
|
attrs = {
|
44
44
|
:name => "viewport",
|
45
45
|
:content => "width=device-width, user-scalable=yes, initial-scale=1.0"
|
46
46
|
}
|
47
|
-
|
47
|
+
|
48
48
|
tag(:meta, attrs).should == "<meta name=\"#{attrs[:name]}\" content=\"#{attrs[:content]}\">"
|
49
49
|
end
|
50
|
-
|
50
|
+
|
51
51
|
it "should ignore passed attributes with a nil value" do
|
52
52
|
tag(:div, :class => nil, :content => "They have absolutely no class, and they're always on the hustle.").should == "<div>They have absolutely no class, and they're always on the hustle.</div>"
|
53
53
|
end
|
54
|
-
|
54
|
+
|
55
55
|
it "should output all class names supplied as an array" do
|
56
56
|
tag(:div, :class => [:foo, :bar], :content => "hello world").should == "<div class=\"foo bar\">hello world</div>"
|
57
57
|
end
|
58
|
-
|
58
|
+
|
59
59
|
it "should automatically close span tags when no content is supplied" do
|
60
60
|
tag(:span).should == "<span></span>"
|
61
61
|
end
|
62
|
-
|
62
|
+
|
63
63
|
it "should output a new line after passing a block to a tag" do
|
64
64
|
pending "Need a mechanism for capturing erb output within a passed block"
|
65
65
|
output = tag :div do
|
66
66
|
"hello world"
|
67
67
|
end
|
68
|
-
|
68
|
+
|
69
69
|
output.should end_with "\n"
|
70
70
|
end
|
71
|
-
|
71
|
+
|
72
72
|
it "should output select tags with a supplied list of options" do
|
73
73
|
attrs = {
|
74
74
|
:name => "colour",
|
@@ -80,10 +80,10 @@ describe Herbie::Helpers do
|
|
80
80
|
{:content => "Orange", :value => :legendary}
|
81
81
|
]
|
82
82
|
}
|
83
|
-
|
83
|
+
|
84
84
|
tag(:select, attrs).should == "<select name=\"colour\"><option value=\"common\">White</option><option value=\"uncommon\">Green</option><option value=\"rare\">Blue</option><option value=\"epic\">Purple</option><option value=\"legendary\">Orange</option></select>"
|
85
85
|
end
|
86
|
-
|
86
|
+
|
87
87
|
it "should output select tags with a supplied list of optgroups" do
|
88
88
|
attrs = {
|
89
89
|
:name => "vehicles",
|
@@ -114,10 +114,10 @@ describe Herbie::Helpers do
|
|
114
114
|
}
|
115
115
|
]
|
116
116
|
}
|
117
|
-
|
117
|
+
|
118
118
|
tag(:select, attrs).should == "<select name=\"vehicles\"><optgroup label=\"Cars\"><option value=\"ferrari\">Ferrari</option><option value=\"vw\">Volkswagen</option><option value=\"ford\">Ford</option></optgroup><optgroup label=\"Trucks\"><option value=\"volvo\">Volvo</option><option value=\"toyota\">Toyota</option><option value=\"gm\">General Motors</option></optgroup><optgroup label=\"Bikes\"><option value=\"suzuki\">Suzuki</option><option value=\"ducati\">Ducati</option><option value=\"kawasaki\">Kawasaki</option></optgroup></select>"
|
119
119
|
end
|
120
|
-
|
120
|
+
|
121
121
|
it "should output select tags with a mixed list of optgroups and options" do
|
122
122
|
attrs = {
|
123
123
|
:name => "vehicles",
|
@@ -149,7 +149,7 @@ describe Herbie::Helpers do
|
|
149
149
|
}
|
150
150
|
]
|
151
151
|
}
|
152
|
-
|
152
|
+
|
153
153
|
tag(:select, attrs).should == "<select name=\"vehicles\"><option>— Choose —</option><optgroup label=\"Cars\"><option value=\"ferrari\">Ferrari</option><option value=\"vw\">Volkswagen</option><option value=\"ford\">Ford</option></optgroup><optgroup label=\"Trucks\"><option value=\"volvo\">Volvo</option><option value=\"toyota\">Toyota</option><option value=\"gm\">General Motors</option></optgroup><optgroup label=\"Bikes\"><option value=\"suzuki\">Suzuki</option><option value=\"ducati\">Ducati</option><option value=\"kawasaki\">Kawasaki</option></optgroup></select>"
|
154
154
|
end
|
155
155
|
|
@@ -235,7 +235,7 @@ MARKUP
|
|
235
235
|
script("https://code.jquery.com/jquery.js").should == "<script type=\"text/javascript\" charset=\"utf-8\" src=\"https://code.jquery.com/jquery.js\"></script>" and
|
236
236
|
script("//code.jquery.com/jquery.js").should == "<script type=\"text/javascript\" charset=\"utf-8\" src=\"//code.jquery.com/jquery.js\"></script>"
|
237
237
|
end
|
238
|
-
|
238
|
+
|
239
239
|
it "should output a modified URL with .min.js as the file extension when the minified option is true" do
|
240
240
|
script("/path/to/script.js", :minified => true).should == "<script type=\"text/javascript\" charset=\"utf-8\" src=\"/path/to/script.min.js\"></script>"
|
241
241
|
end
|
@@ -272,7 +272,7 @@ MARKUP
|
|
272
272
|
media = "screen and (min-width:500px)"
|
273
273
|
style("/style/foo.css", :media => media).should == "<link rel=\"stylesheet\" type=\"text/css\" href=\"/style/foo.css\" media=\"#{media}\">"
|
274
274
|
end
|
275
|
-
|
275
|
+
|
276
276
|
it "should output a modified URL with .min.css as the file extension when the minified option is true" do
|
277
277
|
style("/style/foo.css", :minified => true).should == "<link rel=\"stylesheet\" type=\"text/css\" href=\"/style/foo.min.css\">"
|
278
278
|
end
|
@@ -318,17 +318,4 @@ MARKUP
|
|
318
318
|
link_to(href, text, attrs, &markup_block).should == "<a href=\"#{href}\" class=\"#{attrs[:class]}\">#{capture_erb(&markup_block)}</a>"
|
319
319
|
end
|
320
320
|
end
|
321
|
-
|
322
|
-
describe "content helpers" do
|
323
|
-
it "should accept a named block of content which can then be displayed elsewhere later" do
|
324
|
-
pending "Need a mechanism for capturing erb output within a passed block"
|
325
|
-
|
326
|
-
content_for :script do
|
327
|
-
"<script type=\"text/javascript\" charset=\"utf-8\" src=\"/application.js\">"
|
328
|
-
# Tilt['erb'].new { "%><%= script 'application.js' %><%" }
|
329
|
-
end
|
330
|
-
|
331
|
-
content_for(:script).should == "<script type=\"text/javascript\" charset=\"utf-8\" src=\"/application.js\">"
|
332
|
-
end
|
333
|
-
end
|
334
|
-
end
|
321
|
+
end
|
data/spec/spec.opts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
--color --format documentation
|
1
|
+
--color --format documentation
|
metadata
CHANGED
@@ -1,94 +1,83 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: herbie
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.4.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Ben Darlow
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2015-03-06 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: tilt
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - ">="
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - ">="
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '0'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: erubis
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - ">="
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '0'
|
38
34
|
type: :runtime
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - ">="
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '0'
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: rspec
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- - ~>
|
45
|
+
- - "~>"
|
52
46
|
- !ruby/object:Gem::Version
|
53
47
|
version: '2.6'
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- - ~>
|
52
|
+
- - "~>"
|
60
53
|
- !ruby/object:Gem::Version
|
61
54
|
version: '2.6'
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: rspec-expectations
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
|
-
- - ~>
|
59
|
+
- - "~>"
|
68
60
|
- !ruby/object:Gem::Version
|
69
61
|
version: '2.14'
|
70
62
|
type: :development
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
|
-
- - ~>
|
66
|
+
- - "~>"
|
76
67
|
- !ruby/object:Gem::Version
|
77
68
|
version: '2.14'
|
78
69
|
- !ruby/object:Gem::Dependency
|
79
70
|
name: colored
|
80
71
|
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
72
|
requirements:
|
83
|
-
- -
|
73
|
+
- - ">="
|
84
74
|
- !ruby/object:Gem::Version
|
85
75
|
version: '0'
|
86
76
|
type: :development
|
87
77
|
prerelease: false
|
88
78
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
79
|
requirements:
|
91
|
-
- -
|
80
|
+
- - ">="
|
92
81
|
- !ruby/object:Gem::Version
|
93
82
|
version: '0'
|
94
83
|
description: Lovable HTML view helpers for use with ERB.
|
@@ -97,38 +86,38 @@ executables: []
|
|
97
86
|
extensions: []
|
98
87
|
extra_rdoc_files: []
|
99
88
|
files:
|
89
|
+
- lib/herbie.rb
|
100
90
|
- lib/herbie/erb_helpers.rb
|
101
91
|
- lib/herbie/generic_helpers.rb
|
102
92
|
- lib/herbie/html_helpers.rb
|
103
|
-
- lib/herbie.rb
|
104
93
|
- spec/herbie_spec.rb
|
105
94
|
- spec/spec.opts
|
106
95
|
- spec/spec_helper.rb
|
107
96
|
homepage: http://github.com/kapowaz/herbie
|
108
97
|
licenses: []
|
98
|
+
metadata: {}
|
109
99
|
post_install_message:
|
110
100
|
rdoc_options: []
|
111
101
|
require_paths:
|
112
102
|
- lib
|
113
103
|
required_ruby_version: !ruby/object:Gem::Requirement
|
114
|
-
none: false
|
115
104
|
requirements:
|
116
|
-
- -
|
105
|
+
- - ">="
|
117
106
|
- !ruby/object:Gem::Version
|
118
|
-
version: 1.
|
107
|
+
version: 2.1.5
|
119
108
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
120
|
-
none: false
|
121
109
|
requirements:
|
122
|
-
- -
|
110
|
+
- - ">="
|
123
111
|
- !ruby/object:Gem::Version
|
124
112
|
version: '0'
|
125
113
|
requirements: []
|
126
114
|
rubyforge_project:
|
127
|
-
rubygems_version:
|
115
|
+
rubygems_version: 2.2.2
|
128
116
|
signing_key:
|
129
|
-
specification_version:
|
117
|
+
specification_version: 4
|
130
118
|
summary: herbie
|
131
119
|
test_files:
|
132
120
|
- spec/herbie_spec.rb
|
133
121
|
- spec/spec.opts
|
134
122
|
- spec/spec_helper.rb
|
123
|
+
has_rdoc:
|