visionmedia-tagz 1.0.1 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/History.rdoc CHANGED
@@ -1,4 +1,13 @@
1
1
 
2
+ === 1.1.1 / 2009-08-05
3
+
4
+ * Fixed gemspec dependencies
5
+
6
+ === 1.1.0 / 2009-08-05
7
+
8
+ * Added Tagz::Tag
9
+ * Fixed buffer issue
10
+
2
11
  === 1.0.1 / 2009-05-08
3
12
 
4
13
  * Github build me!
data/Manifest CHANGED
@@ -1,5 +1,5 @@
1
+ examples/small.rb
1
2
  History.rdoc
2
- lib/tagz/buffer.rb
3
3
  lib/tagz/helpers.rb
4
4
  lib/tagz/import.rb
5
5
  lib/tagz/tagz.rb
@@ -8,7 +8,6 @@ lib/tagz.rb
8
8
  Manifest
9
9
  Rakefile
10
10
  README.rdoc
11
- spec/buffer_spec.rb
12
11
  spec/helpers_spec.rb
13
12
  spec/spec_helper.rb
14
13
  spec/tagz_spec.rb
data/README.rdoc CHANGED
@@ -25,7 +25,6 @@ Tagz does not force you to use anything, simply include
25
25
  the autoloaded modules where you like:
26
26
 
27
27
  include Tagz
28
- include Tagz::Buffer
29
28
  include Tagz::Helpers
30
29
 
31
30
  Or import them all!
@@ -39,6 +38,76 @@ and super extendable forms, check out:
39
38
 
40
39
  http://github.com/visionmedia/formz
41
40
 
41
+ == Tag Mixin Example
42
+
43
+ Every tag is generated using #create_tag internally, allowing you to
44
+ provide labels, wrapping elements for styling, descriptions, and much more.
45
+ Below is an example mixin providing Wrappers:
46
+
47
+ module Wrappers
48
+ WRAP_TAGS = :input, :textarea, :select
49
+
50
+ def create_tag name, contents, attrs, &block
51
+ if name.in? WRAP_TAGS
52
+ classes = "field-#{attrs[:name].to_s.gsub('[', '-').gsub(']', '')}"
53
+ classes.add_class "field-#{attrs[:type]}" if :type.in? attrs
54
+ tag :div, super, :class => classes
55
+ else
56
+ super
57
+ end
58
+ end
59
+ end
60
+
61
+ puts tag :input, :type => :text, :name => :username
62
+
63
+ # => <input type="text" name="username"/>
64
+
65
+ include Wrappers
66
+
67
+ puts tag :input, :type => :text, :name => :username
68
+
69
+ # => <div class="field-username field-text">
70
+ <input type="text" name="username"/>
71
+ </div>
72
+
73
+ == Tag DSL Example
74
+
75
+ Below is a simplified example for adding
76
+ a menu DSL to your application. Any method
77
+ called on Tagz::Tag may append its own contents,
78
+ creating an elegant DSL.
79
+
80
+ NOTE: When extending Tagz::Tag you should use
81
+ #Tags.tag rather than #tag to prevent duplication since
82
+ #tag appends contents on every call.
83
+
84
+ def menu attrs = {}, &block
85
+ tag :ul, attrs, &block
86
+ end
87
+
88
+ class Tagz::Tag
89
+ def item contents, uri
90
+ @contents << Tagz.tag(:li, Tagz.tag(:a, contents, :href => uri)).to_s
91
+ end
92
+ end
93
+
94
+ markup = menu :id => 'navigation' do
95
+ item 'Main', '/'
96
+ item 'Content', '/content'
97
+ item 'Packages', '/packages'
98
+ item 'Users', '/users'
99
+ item 'Reports', '/reports'
100
+ end
101
+ puts markup
102
+
103
+ # => <ul id="navigation">
104
+   <li><a href="/">Main</a></li>
105
+   <li><a href="/content">Content</a></li>
106
+   <li><a href="/packages">Packages</a></li>
107
+   <li><a href="/users">Users</a></li>
108
+   <li><a href="/reports">Reports</a></li>
109
+ </ul>
110
+
42
111
  == License
43
112
 
44
113
  (The MIT License)
data/Rakefile CHANGED
@@ -10,8 +10,8 @@ Echoe.new "tagz", Tagz::VERSION do |p|
10
10
  p.email = "tj@vision-media.ca"
11
11
  p.summary = "Framework independant tag helpers"
12
12
  p.url = "http://github.com/visionmedia/tagz"
13
- p.runtime_dependencies << 'visionmedia-rext >= 0.1.0'
14
- p.development_dependencies << 'rspec_hpricot_matchers >= 1.0.0'
13
+ p.runtime_dependencies << 'visionmedia-rext >=0.2.2'
14
+ p.development_dependencies << 'rspec_hpricot_matchers >=1.0.0'
15
15
  end
16
16
 
17
17
  Dir['tasks/**/*.rake'].sort.each { |f| load f }
data/examples/small.rb ADDED
@@ -0,0 +1,54 @@
1
+
2
+ $:.unshift File.dirname(__FILE__) + '/../lib'
3
+ require 'rubygems'
4
+ require 'tagz/import'
5
+
6
+ # Example Tagz mixin
7
+
8
+ module Wrappers
9
+ WRAP_TAGS = :input, :textarea, :select
10
+
11
+ def create_tag name, contents, attrs, &block
12
+ if name.in? WRAP_TAGS
13
+ classes = "field-#{attrs[:name].to_s.gsub('[', '-').gsub(']', '')}"
14
+ classes.add_class "field-#{attrs[:type]}" if :type.in? attrs
15
+ tag :div, super, :class => classes
16
+ else
17
+ super
18
+ end
19
+ end
20
+ end
21
+
22
+ include Wrappers
23
+
24
+ markup = tag :form, :id => :register, :action => '/register' do
25
+ tag :fieldset do
26
+ tag :legend, 'Register:'
27
+ tag :input, :type => :text, :name => :username
28
+ tag :input, :type => :password, :name => :password
29
+ end
30
+ tag :div, :id => 'buttons' do
31
+ tag :input, :type => :submit, :name => :op, :value => 'Join'
32
+ tag :input, :type => :button, :name => :op, :value => 'Cancel'
33
+ end
34
+ end
35
+ puts markup
36
+
37
+ def menu attrs = {}, &block
38
+ tag :ul, attrs, &block
39
+ end
40
+
41
+ class Tagz::Tag
42
+ def item contents, uri
43
+ @contents << Tagz.tag(:li, Tagz.tag(:a, contents, :href => uri)).to_s
44
+ end
45
+ end
46
+
47
+ markup = menu :id => 'navigation' do
48
+ item 'Main', '/'
49
+ item 'Content', '/content'
50
+ item 'Packages', '/packages'
51
+ item 'Users', '/users'
52
+ item 'Reports', '/reports'
53
+ end
54
+ puts markup
data/lib/tagz.rb CHANGED
@@ -26,6 +26,5 @@ require 'tagz/tagz'
26
26
  require 'tagz/version'
27
27
 
28
28
  module Tagz
29
- autoload :Buffer, 'tagz/buffer'
30
29
  autoload :Helpers, 'tagz/helpers'
31
30
  end
data/lib/tagz/helpers.rb CHANGED
@@ -1,106 +1,109 @@
1
1
 
2
- ##
3
- # = Helpers
4
- #
5
- # Tagz::Helpers consists of methods which
6
- # assist creation of common tag combinations
7
- # and standards. For example images may simply
8
- # call image('foo.png'), as a shortcut for
9
- # tag(:img, :src => 'foo.png').
10
- #
11
-
12
- module Tagz::Helpers
13
-
14
- module_function
15
-
16
- ##
17
- # Return image tag to _path_.
18
- #
19
- # === Examples
20
- #
21
- # image 'foo.png'
22
- # # => <img src="foo.png" />
23
- #
24
- # image 'foo.png', :alt => 'Kung-foo'
25
- # # => <img src="foo.png" alt="Kung-foo">
26
- #
27
-
28
- def image path, attrs = {}
29
- tag :img, { :src => path }.merge(attrs)
30
- end
31
-
32
- ##
33
- # Return stylesheet link tag to _path_. When a _block_
34
- # is passed, a style tag will be created with the yielded
35
- # value as its contents.
36
- #
37
- # === Examples
38
- #
39
- # stylesheet do
40
- # "body {
41
- # color: blue;
42
- # }"
43
- # end
44
- # # => <style>body { ... }</style>
45
- #
46
- #
47
- # stylesheet 'style.css', :media => :print
48
- # # => <link rel="stylesheet" href="style.css" media="print" />
49
- #
50
-
51
- def stylesheet path = nil, attrs = {}, &block
52
- return tag(:style, yield, { :type => 'text/css' }.merge(attrs)) if block
53
- tag :link, { :rel => 'stylesheet', :href => path }.merge(attrs)
54
- end
55
-
56
- ##
57
- # Return script tag to _path_. When a _block_ is passed,
58
- # a script tag will be created with the yielded value as
59
- # its contents.
60
- #
61
- # === Examples
62
- #
63
- # javascript do
64
- # "foo"
65
- # end
66
- # # => <script type="text/javascript">foo</script>
67
- #
68
- # javascript 'jquery.js'
69
- # # => <script type="text/javascript" src="jquery.js"></script>
70
- #
71
-
72
- def javascript path = nil, attrs = {}, &block
73
- contents = yield if block
74
- tag :script, contents, { :type => 'text/javascript', :src => path }.merge(attrs)
75
- end
76
-
77
- ##
78
- # Return meta tag _name_ with _contents_.
79
- #
80
- # === Examples
81
- #
82
- # meta :keywords, 'foo bar'
83
- # meta :description, 'Welcome to foo bar'
84
- #
85
- # # => <meta name="keywords" contents="foo bar">
86
- # # => <meta name="description" contents="Welcome to foo bar">
87
- #
88
-
89
- def meta name, contents
90
- tag :meta, :name => name, :contents => contents
91
- end
2
+ module Tagz
92
3
 
93
4
  ##
94
- # Return CDATA tag with _contents_.
95
- #
96
- # === Examples
5
+ # = Helpers
97
6
  #
98
- # cdata '<foo>'
99
- # # => <![CDATA[<foo>]]>
7
+ # Tagz::Helpers consists of methods which
8
+ # assist creation of common tag combinations
9
+ # and standards. For example images may simply
10
+ # call image('foo.png'), as a shortcut for
11
+ # tag(:img, :src => 'foo.png').
100
12
  #
101
13
 
102
- def cdata contents
103
- "<![CDATA[#{contents}]]>"
14
+ module Helpers
15
+
16
+ module_function
17
+
18
+ ##
19
+ # Return image tag to _path_.
20
+ #
21
+ # === Examples
22
+ #
23
+ # image 'foo.png'
24
+ # # => <img src="foo.png" />
25
+ #
26
+ # image 'foo.png', :alt => 'Kung-foo'
27
+ # # => <img src="foo.png" alt="Kung-foo">
28
+ #
29
+
30
+ def image path, attrs = {}
31
+ tag :img, { :src => path }.merge(attrs)
32
+ end
33
+
34
+ ##
35
+ # Return stylesheet link tag to _path_. When a _block_
36
+ # is passed, a style tag will be created with the yielded
37
+ # value as its contents.
38
+ #
39
+ # === Examples
40
+ #
41
+ # stylesheet do
42
+ # "body {
43
+ # color: blue;
44
+ # }"
45
+ # end
46
+ # # => <style>body { ... }</style>
47
+ #
48
+ #
49
+ # stylesheet 'style.css', :media => :print
50
+ # # => <link rel="stylesheet" href="style.css" media="print" />
51
+ #
52
+
53
+ def stylesheet path = nil, attrs = {}, &block
54
+ return tag(:style, yield, { :type => 'text/css' }.merge(attrs)) if block
55
+ tag :link, { :rel => 'stylesheet', :href => path }.merge(attrs)
56
+ end
57
+
58
+ ##
59
+ # Return script tag to _path_. When a _block_ is passed,
60
+ # a script tag will be created with the yielded value as
61
+ # its contents.
62
+ #
63
+ # === Examples
64
+ #
65
+ # javascript do
66
+ # "foo"
67
+ # end
68
+ # # => <script type="text/javascript">foo</script>
69
+ #
70
+ # javascript 'jquery.js'
71
+ # # => <script type="text/javascript" src="jquery.js"></script>
72
+ #
73
+
74
+ def javascript path = nil, attrs = {}, &block
75
+ contents = yield if block
76
+ tag :script, contents, { :type => 'text/javascript', :src => path }.merge(attrs)
77
+ end
78
+
79
+ ##
80
+ # Return meta tag _name_ with _contents_.
81
+ #
82
+ # === Examples
83
+ #
84
+ # meta :keywords, 'foo bar'
85
+ # meta :description, 'Welcome to foo bar'
86
+ #
87
+ # # => <meta name="keywords" contents="foo bar">
88
+ # # => <meta name="description" contents="Welcome to foo bar">
89
+ #
90
+
91
+ def meta name, contents
92
+ tag :meta, :name => name, :contents => contents
93
+ end
94
+
95
+ ##
96
+ # Return CDATA tag with _contents_.
97
+ #
98
+ # === Examples
99
+ #
100
+ # cdata '<foo>'
101
+ # # => <![CDATA[<foo>]]>
102
+ #
103
+
104
+ def cdata contents
105
+ "<![CDATA[#{contents}]]>"
106
+ end
107
+
104
108
  end
105
-
106
109
  end
data/lib/tagz/import.rb CHANGED
@@ -2,5 +2,4 @@
2
2
  require 'tagz'
3
3
 
4
4
  include Tagz
5
- include Tagz::Buffer
6
5
  include Tagz::Helpers
data/lib/tagz/tagz.rb CHANGED
@@ -49,6 +49,54 @@ module Tagz
49
49
 
50
50
  BOOLEAN_ATTRIBUTES = :selected, :checked, :disabled, :readonly, :multiple, :defer
51
51
 
52
+ #--
53
+ # Tag
54
+ #++
55
+
56
+ class Tag
57
+
58
+ ##
59
+ # Tag name.
60
+
61
+ attr_reader :name
62
+
63
+ ##
64
+ # Contents string.
65
+
66
+ attr_reader :contents
67
+
68
+ ##
69
+ # Attributes hash.
70
+
71
+ attr_reader :attrs
72
+
73
+ ##
74
+ # Block proc.
75
+
76
+ attr_reader :proc
77
+
78
+ #:nodoc:
79
+
80
+ def initialize name, contents = nil, attrs = {}, &block
81
+ @name, @contents, @attrs, @proc = name, (contents || ''), attrs, block
82
+ block.yield_or_eval self if block
83
+ end
84
+
85
+ ##
86
+ # Append tag to contents.
87
+
88
+ def tag *args, &block
89
+ @contents << Tagz.tag(*args, &block).to_s
90
+ end
91
+
92
+ ##
93
+ # Return tag string.
94
+
95
+ def to_s
96
+ create_tag name, contents, attrs, &proc
97
+ end
98
+ end
99
+
52
100
  module_function
53
101
 
54
102
  ##
@@ -75,7 +123,7 @@ module Tagz
75
123
  # tag :div, 'hello', :id => 'comment'
76
124
  # # => <div id="comment">hello</div>
77
125
  #
78
- # tag :div :id => 'comment'
126
+ # tag :div, :id => 'comment'
79
127
  # # => <div id="comment"></div>
80
128
  #
81
129
  # tag :div do
@@ -83,18 +131,23 @@ module Tagz
83
131
  # end
84
132
  # # => <div><p>Hello World</p></div>
85
133
  #
134
+ # tag :div do |div|
135
+ # div.tag :p, 'Hello World'
136
+ # end
137
+ # # => <div><p>Hello World</p></div>
138
+ #
86
139
  # tag :input, :type => :checkbox, :checked => true
87
140
  # # => <input type="checkbox" checked="checked" />
88
141
  #
89
142
 
90
143
  def tag name, contents = nil, attrs = {}, &block
91
144
  attrs, contents = contents, nil if contents.is_a? Hash
92
- create_tag name, contents, attrs, &block
145
+ Tag.new(name, contents, attrs, &block).to_s
93
146
  end
94
147
 
95
148
  #:stopdoc:
96
149
 
97
- def create_tag name, contents = nil, attrs = {}, &block
150
+ def create_tag name, contents = nil, attrs = {}
98
151
  self_closing_tag?(name) ?
99
152
  self_closing_tag(name, attrs) :
100
153
  open_tag(name, attrs) + contents.to_s + closing_tag(name)
data/lib/tagz/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
 
2
2
  module Tagz
3
- VERSION = '1.0.1'
3
+ VERSION = '1.1.1'
4
4
  end
data/spec/tagz_spec.rb CHANGED
@@ -21,5 +21,66 @@ describe Tagz do
21
21
  tag(:input, :type => :checkbox, :checked => true).should have_tag('input[@checked=checked]')
22
22
  tag(:input, :type => :checkbox, :checked => false).should_not have_tag('input[@checked=checked]')
23
23
  end
24
+
25
+ it "should accept blocks to populate contents" do
26
+ markup = tag :form do |div|
27
+ div.tag :h2, 'Login'
28
+ div.tag :input, :type => :text
29
+ div.tag :input, :type => :submit, :value => 'Submit'
30
+ end
31
+ markup.should have_tag('form') do |form|
32
+ form.should have_tag('h2', 'Login')
33
+ form.should have_tag('input[@type=text]')
34
+ form.should have_tag('input[@type=submit]')
35
+ end
36
+ end
37
+
38
+ it "should evaluate blocks to populate contents" do
39
+ markup = tag :form do
40
+ tag :h2, 'Login'
41
+ tag :input, :type => :text
42
+ tag :input, :type => :submit, :value => 'Submit'
43
+ end
44
+ markup.should have_tag('form') do |form|
45
+ form.should have_tag('h2', 'Login')
46
+ form.should have_tag('input[@type=text]')
47
+ form.should have_tag('input[@type=submit]')
48
+ end
49
+ end
50
+
51
+ it "should work with deep nesting" do
52
+ markup = tag :form do |div|
53
+ div.tag :h2, 'Comment'
54
+ div.tag :div do |div|
55
+ div.tag :textarea, :id => 'comments'
56
+ div.tag :input, :type => 'submit'
57
+ end
58
+ end
59
+ markup.should have_tag('form') do |form|
60
+ form.should have_tag('h2', 'Comment')
61
+ form.should have_tag('div') do |div|
62
+ div.should have_tag('textarea[@id=comments]')
63
+ div.should have_tag('input[@type=submit]')
64
+ end
65
+ end
66
+ end
67
+
68
+ it "should work with deep nesting when evaluating blocks" do
69
+ markup = tag :form do
70
+ tag :h2, 'Comment'
71
+ tag :div do
72
+ tag :textarea, :id => 'comments'
73
+ tag :input, :type => 'submit'
74
+ end
75
+ end
76
+ markup.should have_tag('form') do |form|
77
+ form.should have_tag('h2', 'Comment')
78
+ form.should have_tag('div') do |div|
79
+ div.should have_tag('textarea[@id=comments]')
80
+ div.should have_tag('input[@type=submit]')
81
+ end
82
+ end
83
+ end
84
+
24
85
  end
25
86
  end
data/tagz.gemspec CHANGED
@@ -2,20 +2,20 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{tagz}
5
- s.version = "1.0.1"
5
+ s.version = "1.1.1"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["TJ Holowaychuk"]
9
- s.date = %q{2009-05-08}
9
+ s.date = %q{2009-08-05}
10
10
  s.description = %q{Framework independant tag helpers}
11
11
  s.email = %q{tj@vision-media.ca}
12
- s.extra_rdoc_files = ["lib/tagz/buffer.rb", "lib/tagz/helpers.rb", "lib/tagz/import.rb", "lib/tagz/tagz.rb", "lib/tagz/version.rb", "lib/tagz.rb", "README.rdoc", "tasks/docs.rake", "tasks/gemspec.rake", "tasks/spec.rake"]
13
- s.files = ["History.rdoc", "lib/tagz/buffer.rb", "lib/tagz/helpers.rb", "lib/tagz/import.rb", "lib/tagz/tagz.rb", "lib/tagz/version.rb", "lib/tagz.rb", "Manifest", "Rakefile", "README.rdoc", "spec/buffer_spec.rb", "spec/helpers_spec.rb", "spec/spec_helper.rb", "spec/tagz_spec.rb", "tagz.gemspec", "tasks/docs.rake", "tasks/gemspec.rake", "tasks/spec.rake"]
12
+ s.extra_rdoc_files = ["lib/tagz/helpers.rb", "lib/tagz/import.rb", "lib/tagz/tagz.rb", "lib/tagz/version.rb", "lib/tagz.rb", "README.rdoc", "tasks/docs.rake", "tasks/gemspec.rake", "tasks/spec.rake"]
13
+ s.files = ["examples/small.rb", "History.rdoc", "lib/tagz/helpers.rb", "lib/tagz/import.rb", "lib/tagz/tagz.rb", "lib/tagz/version.rb", "lib/tagz.rb", "Manifest", "Rakefile", "README.rdoc", "spec/helpers_spec.rb", "spec/spec_helper.rb", "spec/tagz_spec.rb", "tagz.gemspec", "tasks/docs.rake", "tasks/gemspec.rake", "tasks/spec.rake"]
14
14
  s.homepage = %q{http://github.com/visionmedia/tagz}
15
15
  s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Tagz", "--main", "README.rdoc"]
16
16
  s.require_paths = ["lib"]
17
17
  s.rubyforge_project = %q{tagz}
18
- s.rubygems_version = %q{1.3.3}
18
+ s.rubygems_version = %q{1.3.5}
19
19
  s.summary = %q{Framework independant tag helpers}
20
20
 
21
21
  if s.respond_to? :specification_version then
@@ -23,14 +23,14 @@ Gem::Specification.new do |s|
23
23
  s.specification_version = 3
24
24
 
25
25
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
26
- s.add_runtime_dependency(%q<visionmedia-rext>, [">= 0", "= 0.1.0"])
27
- s.add_development_dependency(%q<rspec_hpricot_matchers>, [">= 0", "= 1.0.0"])
26
+ s.add_runtime_dependency(%q<visionmedia-rext>, [">= 0.2.2"])
27
+ s.add_development_dependency(%q<rspec_hpricot_matchers>, [">= 1.0.0"])
28
28
  else
29
- s.add_dependency(%q<visionmedia-rext>, [">= 0", "= 0.1.0"])
30
- s.add_dependency(%q<rspec_hpricot_matchers>, [">= 0", "= 1.0.0"])
29
+ s.add_dependency(%q<visionmedia-rext>, [">= 0.2.2"])
30
+ s.add_dependency(%q<rspec_hpricot_matchers>, [">= 1.0.0"])
31
31
  end
32
32
  else
33
- s.add_dependency(%q<visionmedia-rext>, [">= 0", "= 0.1.0"])
34
- s.add_dependency(%q<rspec_hpricot_matchers>, [">= 0", "= 1.0.0"])
33
+ s.add_dependency(%q<visionmedia-rext>, [">= 0.2.2"])
34
+ s.add_dependency(%q<rspec_hpricot_matchers>, [">= 1.0.0"])
35
35
  end
36
36
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: visionmedia-tagz
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - TJ Holowaychuk
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-05-08 00:00:00 -07:00
12
+ date: 2009-08-05 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -20,10 +20,7 @@ dependencies:
20
20
  requirements:
21
21
  - - ">="
22
22
  - !ruby/object:Gem::Version
23
- version: "0"
24
- - - "="
25
- - !ruby/object:Gem::Version
26
- version: 0.1.0
23
+ version: 0.2.2
27
24
  version:
28
25
  - !ruby/object:Gem::Dependency
29
26
  name: rspec_hpricot_matchers
@@ -32,9 +29,6 @@ dependencies:
32
29
  version_requirements: !ruby/object:Gem::Requirement
33
30
  requirements:
34
31
  - - ">="
35
- - !ruby/object:Gem::Version
36
- version: "0"
37
- - - "="
38
32
  - !ruby/object:Gem::Version
39
33
  version: 1.0.0
40
34
  version:
@@ -45,7 +39,6 @@ executables: []
45
39
  extensions: []
46
40
 
47
41
  extra_rdoc_files:
48
- - lib/tagz/buffer.rb
49
42
  - lib/tagz/helpers.rb
50
43
  - lib/tagz/import.rb
51
44
  - lib/tagz/tagz.rb
@@ -56,8 +49,8 @@ extra_rdoc_files:
56
49
  - tasks/gemspec.rake
57
50
  - tasks/spec.rake
58
51
  files:
52
+ - examples/small.rb
59
53
  - History.rdoc
60
- - lib/tagz/buffer.rb
61
54
  - lib/tagz/helpers.rb
62
55
  - lib/tagz/import.rb
63
56
  - lib/tagz/tagz.rb
@@ -66,7 +59,6 @@ files:
66
59
  - Manifest
67
60
  - Rakefile
68
61
  - README.rdoc
69
- - spec/buffer_spec.rb
70
62
  - spec/helpers_spec.rb
71
63
  - spec/spec_helper.rb
72
64
  - spec/tagz_spec.rb
@@ -76,6 +68,7 @@ files:
76
68
  - tasks/spec.rake
77
69
  has_rdoc: false
78
70
  homepage: http://github.com/visionmedia/tagz
71
+ licenses:
79
72
  post_install_message:
80
73
  rdoc_options:
81
74
  - --line-numbers
@@ -101,7 +94,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
101
94
  requirements: []
102
95
 
103
96
  rubyforge_project: tagz
104
- rubygems_version: 1.2.0
97
+ rubygems_version: 1.3.5
105
98
  signing_key:
106
99
  specification_version: 3
107
100
  summary: Framework independant tag helpers
data/lib/tagz/buffer.rb DELETED
@@ -1,50 +0,0 @@
1
-
2
- ##
3
- # = Buffer
4
- #
5
- # When included, Tagz::Buffer allows a tag's block
6
- # to have several calls to #tag, which are collected
7
- # and assigned as the parent tag's contents.
8
- #
9
- # === Examples
10
- #
11
- # tag :div do
12
- # tag :label, 'Comments:', :for => :comments
13
- # tag :textarea, :id => :comments
14
- # end
15
- #
16
- # <div>
17
- # <label for="comments">Comments:</label>
18
- # <textarea id="comments"></textarea>
19
- # </div>
20
- #
21
-
22
- module Tagz::Buffer
23
-
24
- #:stopdoc:
25
-
26
- class Base
27
- def initialize
28
- @buffer = ''
29
- end
30
-
31
- def create_tag *args, &block
32
- @buffer << Buffer.create_tag(*args, &block)
33
- end
34
-
35
- def to_s
36
- @buffer
37
- end
38
- end
39
-
40
- def create_tag name, contents, attrs, &block
41
- if block
42
- buffer = Base.new
43
- buffer.instance_eval &block
44
- super name, "#{contents}#{buffer}", attrs
45
- else
46
- super
47
- end
48
- end
49
-
50
- end
data/spec/buffer_spec.rb DELETED
@@ -1,27 +0,0 @@
1
-
2
- describe Tagz do
3
- describe Buffer do
4
- it "should buffer all tag contents within a block" do
5
- markup = tag :div do
6
- tag :label, 'Comments:', :for => :comments
7
- tag :textarea, :id => :comments
8
- end
9
- markup.should have_tag('div') do |div|
10
- div.should have_tag('label[@for=comments]', 'Comments:')
11
- div.should have_tag('textarea[@id=comments]')
12
- end
13
- end
14
-
15
- it "should prepend contents when both contents and block are present" do
16
- markup = tag :div, 'Cookies' do
17
- tag :label, 'Comments:', :for => :comments
18
- tag :textarea, :id => :comments
19
- end
20
- markup.should have_tag('div') do |div|
21
- div.inner_text.should match(/^Cookies/)
22
- div.should have_tag('label[@for=comments]', 'Comments:')
23
- div.should have_tag('textarea[@id=comments]')
24
- end
25
- end
26
- end
27
- end