rubified 0.1.0 → 0.1.1

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.
@@ -31,13 +31,27 @@ module Rubified
31
31
  # </body>
32
32
  # </html
33
33
  module Canvas
34
+ # Add a method for a specific XML/HTML tag class.
34
35
  def self.add_tag_method(tclass)
35
- define_method(tclass.to_s.split("::").last.downcase) do |params={}, &block|
36
+ n = tclass.to_s.split("::").last.downcase
37
+ #puts n
38
+ =begin
39
+ define_method(n) do |params={}, &block|
36
40
  # Figure out what class to use by the method name.
41
+ #puts __method__
37
42
  tagclass = Rubified::Tag.const_get((__method__).capitalize)
38
43
  # Create a new tag then run it
39
44
  tagclass.new(params).to_html(&block)
40
45
  end
46
+ =end
47
+ eval "
48
+ def #{n}(params={}, &block)
49
+ # Determine what class to use by the method name.
50
+ tagclass = #{tclass}
51
+ # Create a new tag then convert it.
52
+ tagclass.new(params).to_html(&block)
53
+ end
54
+ "
41
55
  end
42
56
  end
43
57
  end
data/lib/rubified/tag.rb CHANGED
@@ -2,11 +2,7 @@ class Rubified::Tag
2
2
  # Create and returns a new tag class with the name +name+. To create a tag that
3
3
  # does NOT use a matched pair, set paired to false. Tags like <img> need this.
4
4
  def self.new_tag(name, paired=true)
5
- # Store the new tag's name in a constant; the block to create the new class
6
- # won't keep local variables. A bit of a cheat
7
- const_set(:Name, name)
8
5
  newbie = Class.new(self)
9
- remove_const(:Name)
10
6
  const_set(name.capitalize, newbie)
11
7
  newbie.const_set(:Paired, paired)
12
8
  newbie
data/lib/rubified/tags.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Pre-load a small list of HTML tags.
1
+ # The list of HTML tags. It's not complete.
2
2
  tags = {
3
3
  :html=>true,
4
4
  :head=>true,
@@ -15,5 +15,9 @@ tags = {
15
15
  }
16
16
 
17
17
  tags.each {|tag, paired|
18
- Rubified::Tag.new_tag(tag, paired)
18
+ # First, create a new class for this tag.
19
+ newbie = Rubified::Tag.new_tag(tag, paired)
20
+ # Then create a corresponding method for it.
21
+ #puts newbie
22
+ Rubified::Canvas.add_tag_method(newbie)
19
23
  }
data/lib/rubified.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module Rubified
2
2
  require 'ext/object'
3
3
  require 'rubified/tag'
4
- require 'rubified/tags'
5
4
  require 'rubified/canvas'
5
+ require 'rubified/tags'
6
6
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: rubified
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.0
5
+ version: 0.1.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - J. Wostenberg