@@ -5,55 +5,50 @@ class Abstract
5
5
def_class :AbstractDoubleTag , :AbstractTag do ###import
6
6
nil
7
7
8
- # defined by class_eval because there is a error cased by super
9
- # super from singleton method that is defined to multiple classes is not supported;
10
- # this will be fixed in 1.9.3 or later (NotImplementedError)
11
- class_eval <<-RUBY , __FILE__ , __LINE__ + 1
12
- # @api private
13
- def initialize(builder)
14
- super
15
- @content = nil
16
- end
8
+ # @api private
9
+ def initialize ( builder )
10
+ super
11
+ @content = nil
12
+ end
17
13
18
- # allows data-* attributes and id, classes by method_missing
19
- def method_missing(method, *args, &block)
20
- method = method.to_s
21
- if method =~ METHOD_MISSING_REGEXP
22
- if $1
23
- self.rclass.add_attributes Data::Attribute.new(method.to_sym, :string)
24
- self.send method, *args, &block
25
- else
26
- self.content(args[0]) if args[0]
27
- self.__send__($3 == '!' ? :id : :class, $2, &block)
28
- end
14
+ # allows data-* attributes and id, classes by method_missing
15
+ def method_missing ( method , *args , &block )
16
+ method = method . to_s
17
+ if method =~ METHOD_MISSING_REGEXP
18
+ if $1
19
+ self . rclass . add_attributes Data ::Attribute . new ( method . to_sym , :string )
20
+ self . send method , *args , &block
29
21
else
30
- super(method, *args, &block)
22
+ self . content ( args [ 0 ] ) if args [ 0 ]
23
+ self . __send__ ( $3 == '!' ? :id : :class , $2, &block )
31
24
end
25
+ else
26
+ super ( method , *args , &block )
32
27
end
28
+ end
33
29
34
- # @api private
35
- def open(*args, &block)
36
- attributes = if args.last.is_a?(Hash)
37
- args.pop
38
- end
39
- content args[0]
40
- super attributes
41
- @stack << @tag_name
42
- if block
43
- with &block
44
- else
45
- self
46
- end
30
+ # @api private
31
+ def open ( *args , &block )
32
+ attributes = if args . last . is_a? ( Hash )
33
+ args . pop
34
+ end
35
+ content args [ 0 ]
36
+ super attributes
37
+ @stack << @tag_name
38
+ if block
39
+ with &block
40
+ else
41
+ self
47
42
end
48
- RUBY
43
+ end
49
44
50
45
# @api private
51
46
# closes the tag
52
47
def flush
53
48
flush_classes
54
- @output << Strings :: GT
49
+ @output << @_str_gt
55
50
@output << CGI . escapeHTML ( @content ) if @content
56
- @output << Strings :: SLASH_LT << @stack . pop << Strings :: GT
51
+ @output << @_str_slash_lt << @stack . pop << @_str_gt
57
52
@content = nil
58
53
end
59
54
@@ -76,45 +71,43 @@ def content(content)
76
71
# end # => <div id="id">content</div>
77
72
def with
78
73
flush_classes
79
- @output << Strings :: GT
74
+ @output << @_str_gt
80
75
@content = nil
81
76
@builder . current = nil
82
77
yield
83
78
#if (content = yield).is_a?(String)
84
79
# @output << EscapeUtils.escape_html(content)
85
80
#end
86
81
@builder . flush
87
- @output << Strings :: SLASH_LT << @stack . pop << Strings :: GT
82
+ @output << @_str_slash_lt << @stack . pop << @_str_gt
88
83
nil
89
84
end
90
85
91
86
alias_method :w , :with
92
87
93
- class_eval <<-RUBY , __FILE__ , __LINE__ + 1
94
- def mimic(obj, &block)
95
- super(obj, &nil)
96
- return with(&block) if block
97
- self
98
- end
88
+ def mimic ( obj , &block )
89
+ super ( obj , &nil )
90
+ return with ( &block ) if block
91
+ self
92
+ end
99
93
100
- def data(hash, &block)
101
- super(hash, &nil)
102
- return with(&block) if block
103
- self
104
- end
94
+ def data ( hash , &block )
95
+ super ( hash , &nil )
96
+ return with ( &block ) if block
97
+ self
98
+ end
105
99
106
- def attribute(name, value, &block)
107
- super(name, value, &nil)
108
- return with(&block) if block
109
- self
110
- end
100
+ def attribute ( name , value , &block )
101
+ super ( name , value , &nil )
102
+ return with ( &block ) if block
103
+ self
104
+ end
111
105
112
- def attributes(attrs, &block)
113
- super(attrs, &nil)
114
- return with(&block) if block
115
- self
116
- end
117
- RUBY
106
+ def attributes ( attrs , &block )
107
+ super ( attrs , &nil )
108
+ return with ( &block ) if block
109
+ self
110
+ end
118
111
119
112
protected
120
113
@@ -125,20 +118,20 @@ def self.define_attribute_method(attribute)
125
118
126
119
if instance_methods . include? ( attribute . name )
127
120
class_eval <<-RUBY , __FILE__ , __LINE__ + 1
128
- def #{ name } (*args, &block)
129
- super(*args, &nil)
130
- return with(&block) if block
131
- self
132
- end
121
+ def #{ name } (*args, &block)
122
+ super(*args, &nil)
123
+ return with(&block) if block
124
+ self
125
+ end
133
126
RUBY
134
127
else
135
128
content_rendering = attribute_content_rendering ( attribute )
136
129
class_eval <<-RUBY , __FILE__ , __LINE__ + 1
137
- def #{ name } (content#{ ' = true' if attribute . type == :boolean } , &block)
138
- #{ content_rendering }
139
- return with(&block) if block
140
- self
141
- end
130
+ def #{ name } (content#{ ' = true' if attribute . type == :boolean } , &block)
131
+ #{ content_rendering }
132
+ return with(&block) if block
133
+ self
134
+ end
142
135
RUBY
143
136
end
144
137
end
0 commit comments