herbie 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/herbie/html_helpers.rb +5 -3
- data/lib/herbie.rb +1 -1
- data/spec/herbie_spec.rb +14 -0
- data/spec/spec.opts +1 -0
- metadata +20 -3
data/lib/herbie/html_helpers.rb
CHANGED
@@ -2,7 +2,7 @@ module Herbie
|
|
2
2
|
module Helpers
|
3
3
|
def tag(name, attrs={}, &block)
|
4
4
|
if block_given?
|
5
|
-
erb_concat "<#{name}#{' ' + attributes(attrs) unless attrs.nil? || attrs.empty?}>\n#{capture_erb(&block)}\n</#{name}
|
5
|
+
erb_concat "<#{name}#{' ' + attributes(attrs) unless attrs.nil? || attrs.empty?}>\n#{capture_erb(&block)}\n</#{name}>\n"
|
6
6
|
elsif !attrs[:content].nil?
|
7
7
|
case name
|
8
8
|
when :meta
|
@@ -23,6 +23,8 @@ module Herbie
|
|
23
23
|
end
|
24
24
|
end.join
|
25
25
|
"<#{name}#{' ' + attributes(attrs) unless attrs.empty?}>#{option_tags}</#{name}>"
|
26
|
+
when :span
|
27
|
+
"<#{name}#{' ' + attributes(attrs) unless attrs.empty?}></#{name}>"
|
26
28
|
else
|
27
29
|
"<#{name}#{' ' + attributes(attrs) unless attrs.empty?}>"
|
28
30
|
end
|
@@ -60,7 +62,7 @@ module Herbie
|
|
60
62
|
}
|
61
63
|
|
62
64
|
if block_given?
|
63
|
-
erb_concat "#{tag :script, attrs}\n#{capture_erb(&block)}\n</script
|
65
|
+
erb_concat "#{tag :script, attrs}\n#{capture_erb(&block)}\n</script>\n"
|
64
66
|
else
|
65
67
|
source = "/javascripts/#{source}" unless source.nil? || source.match(/^\/{1,2}|^http:\/\/|^https:\/\//)
|
66
68
|
source = source.sub(/.js$/, '.min.js') if source && options[:minified] && !source.match(/.min.js$/)
|
@@ -77,7 +79,7 @@ module Herbie
|
|
77
79
|
|
78
80
|
if block_given?
|
79
81
|
default_attrs.delete :rel
|
80
|
-
erb_concat "#{tag :style, default_attrs.merge(attrs)}\n#{capture_erb(&block)}\n</style
|
82
|
+
erb_concat "#{tag :style, default_attrs.merge(attrs)}\n#{capture_erb(&block)}\n</style>\n"
|
81
83
|
else
|
82
84
|
href = "/stylesheets/#{href}" unless href.match(/^\/{1,2}|^http:\/\/|^https:\/\//)
|
83
85
|
|
data/lib/herbie.rb
CHANGED
data/spec/herbie_spec.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require_relative "../lib/herbie.rb"
|
3
|
+
require "rspec/expectations"
|
3
4
|
|
4
5
|
describe Herbie::Helpers do
|
5
6
|
include Herbie::Helpers
|
@@ -47,6 +48,19 @@ describe Herbie::Helpers do
|
|
47
48
|
tag(:meta, attrs).should == "<meta name=\"#{attrs[:name]}\" content=\"#{attrs[:content]}\">"
|
48
49
|
end
|
49
50
|
|
51
|
+
it "should automatically close span tags when no content is supplied" do
|
52
|
+
tag(:span).should == "<span></span>"
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should output a new line after passing a block to a tag" do
|
56
|
+
pending "Need a mechanism for capturing erb output within a passed block"
|
57
|
+
output = tag :div do
|
58
|
+
"hello world"
|
59
|
+
end
|
60
|
+
|
61
|
+
output.should end_with "\n"
|
62
|
+
end
|
63
|
+
|
50
64
|
it "should output select tags with a supplied list of options" do
|
51
65
|
attrs = {
|
52
66
|
:name => "colour",
|
data/spec/spec.opts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color --format documentation
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: herbie
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-10-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: tilt
|
@@ -59,6 +59,22 @@ dependencies:
|
|
59
59
|
- - ~>
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '2.6'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rspec-expectations
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '2.14'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '2.14'
|
62
78
|
- !ruby/object:Gem::Dependency
|
63
79
|
name: colored
|
64
80
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,6 +102,7 @@ files:
|
|
86
102
|
- lib/herbie/html_helpers.rb
|
87
103
|
- lib/herbie.rb
|
88
104
|
- spec/herbie_spec.rb
|
105
|
+
- spec/spec.opts
|
89
106
|
- spec/spec_helper.rb
|
90
107
|
homepage: http://github.com/kapowaz/herbie
|
91
108
|
licenses: []
|
@@ -113,5 +130,5 @@ specification_version: 3
|
|
113
130
|
summary: herbie
|
114
131
|
test_files:
|
115
132
|
- spec/herbie_spec.rb
|
133
|
+
- spec/spec.opts
|
116
134
|
- spec/spec_helper.rb
|
117
|
-
has_rdoc:
|