herbie 0.1.2 → 0.1.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/lib/herbie/erb_helpers.rb +4 -0
- data/lib/herbie/html_helpers.rb +2 -3
- data/lib/herbie.rb +1 -1
- data/spec/herbie_spec.rb +21 -0
- metadata +27 -5
data/lib/herbie/erb_helpers.rb
CHANGED
data/lib/herbie/html_helpers.rb
CHANGED
@@ -2,8 +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?}>#{capture_erb(&block)}</#{name}>"
|
6
|
-
"<#{name}#{' ' + attributes(attrs) unless attrs.empty?}>#{block.call}</#{name}>" # if we're nesting function calls...
|
5
|
+
erb_concat "<#{name}#{' ' + attributes(attrs) unless attrs.nil? || attrs.empty?}>#{capture_erb(&block)}</#{name}>"
|
7
6
|
elsif !attrs[:content].nil?
|
8
7
|
content = attrs.delete :content
|
9
8
|
"<#{name}#{' ' + attributes(attrs) unless attrs.empty?}>#{content}</#{name}>"
|
@@ -12,7 +11,7 @@ module Herbie
|
|
12
11
|
end
|
13
12
|
end
|
14
13
|
|
15
|
-
# work in progress
|
14
|
+
# work in progress
|
16
15
|
def tags(name, collection, attrs={}, &block)
|
17
16
|
cycle = attrs.delete :cycle
|
18
17
|
result = ""
|
data/lib/herbie.rb
CHANGED
data/spec/herbie_spec.rb
CHANGED
@@ -38,7 +38,26 @@ describe Herbie::Helpers do
|
|
38
38
|
tag(:input, attrs).should == "<input type=\"#{attrs[:type]}\" name=\"#{attrs[:name]}\" value=\"#{attrs[:value]}\" checked>"
|
39
39
|
end
|
40
40
|
|
41
|
+
it "should output tags mixed with ERB" do
|
42
|
+
pending "Need a mechanism for capturing erb output within a passed block"
|
43
|
+
erb_fragment = <<-ERB
|
44
|
+
<% tag :div, :class => "container" do %>
|
45
|
+
Hello world!
|
46
|
+
<% end %>
|
47
|
+
ERB
|
48
|
+
|
49
|
+
html_fragment = <<-HTML
|
50
|
+
<div class="container">
|
51
|
+
Hello world!
|
52
|
+
</div>
|
53
|
+
HTML
|
54
|
+
|
55
|
+
template = Tilt['erb'].new { erb_fragment }
|
56
|
+
template.render.should == html_fragment
|
57
|
+
end
|
58
|
+
|
41
59
|
it "should output all nested tag method calls" do
|
60
|
+
pending "Need a mechanism for capturing erb output within a passed block"
|
42
61
|
markup = "<div class=\"container\"><h1>Status Report</h1></div>"
|
43
62
|
result = tag :div, :class => "container" do
|
44
63
|
tag :h1, :content => "Status Report"
|
@@ -47,6 +66,7 @@ describe Herbie::Helpers do
|
|
47
66
|
end
|
48
67
|
|
49
68
|
it "should output a collection of tags" do
|
69
|
+
pending "Need a mechanism for capturing erb output within a passed block"
|
50
70
|
markup = <<-MARKUP
|
51
71
|
<li><a href="/" title="Back to the homepage">Home</a></li>
|
52
72
|
<li><a href="/shop" title="View all our products">Shop</a></li>
|
@@ -69,6 +89,7 @@ MARKUP
|
|
69
89
|
end
|
70
90
|
|
71
91
|
it "should allow an arbitrary class to be added to alternating elements within the collection" do
|
92
|
+
pending "Need a mechanism for capturing erb output within a passed block"
|
72
93
|
markup = <<-MARKUP
|
73
94
|
<li class="even">Annie</li>
|
74
95
|
<li>Brenda</li>
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: herbie
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.1.
|
5
|
+
version: 0.1.3
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Ben Darlow
|
@@ -14,27 +14,49 @@ date: 2011-10-10 00:00:00 +01:00
|
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
|
-
name:
|
17
|
+
name: tilt
|
18
18
|
prerelease: false
|
19
19
|
requirement: &id001 !ruby/object:Gem::Requirement
|
20
|
+
none: false
|
21
|
+
requirements:
|
22
|
+
- - ">="
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: "0"
|
25
|
+
type: :runtime
|
26
|
+
version_requirements: *id001
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: erubis
|
29
|
+
prerelease: false
|
30
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
31
|
+
none: false
|
32
|
+
requirements:
|
33
|
+
- - ">="
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: "0"
|
36
|
+
type: :runtime
|
37
|
+
version_requirements: *id002
|
38
|
+
- !ruby/object:Gem::Dependency
|
39
|
+
name: rspec
|
40
|
+
prerelease: false
|
41
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
20
42
|
none: false
|
21
43
|
requirements:
|
22
44
|
- - ~>
|
23
45
|
- !ruby/object:Gem::Version
|
24
46
|
version: "2.6"
|
25
47
|
type: :development
|
26
|
-
version_requirements: *
|
48
|
+
version_requirements: *id003
|
27
49
|
- !ruby/object:Gem::Dependency
|
28
50
|
name: colored
|
29
51
|
prerelease: false
|
30
|
-
requirement: &
|
52
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
31
53
|
none: false
|
32
54
|
requirements:
|
33
55
|
- - ">="
|
34
56
|
- !ruby/object:Gem::Version
|
35
57
|
version: "0"
|
36
58
|
type: :development
|
37
|
-
version_requirements: *
|
59
|
+
version_requirements: *id004
|
38
60
|
description: Lovable HTML view helpers for use with ERB.
|
39
61
|
email: ben@kapowaz.net
|
40
62
|
executables: []
|