Changeset 125
- Timestamp:
- 03/28/2007 22:15:06 (20 months ago)
- Location:
- trunk
- Files:
-
- 2 added
- 2 modified
-
lib/hpricot/builder.rb (modified) (4 diffs)
-
lib/hpricot/tag.rb (modified) (1 diff)
-
lib/hpricot/xchar.rb (added)
-
test/test_builder.rb (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/hpricot/builder.rb
r123 r125 1 1 require 'hpricot/tags' 2 require 'hpricot/xchar' 2 3 require 'hpricot/blankslate' 3 4 … … 25 26 def self.set(option, value) 26 27 @@default[option] = value 28 end 29 30 # Write a +string+ to the HTML stream, making sure to escape it. 31 def text!(string) 32 @children << Text.new(Hpricot.xs(string)) 27 33 end 28 34 … … 67 73 childs = [] 68 74 attrs = args.grep(Hash) 69 childs.concat((args - attrs).map { |x| Text.new( x) })75 childs.concat((args - attrs).map { |x| Text.new(Hpricot.xs(x)) }) 70 76 attrs = attrs.inject({}) { |hsh, hsh2| hsh.merge(hsh2) } 71 77 … … 171 177 end 172 178 173 args.push(@attrs) 174 175 if block 179 if block or args.any? 180 args.push(@attrs) 176 181 @builder.tag! @sym, *args, &block 177 else178 @builder.tag! @sym, *args179 182 end 180 183 -
trunk/lib/hpricot/tag.rb
r123 r125 134 134 def pathname; "text()" end 135 135 alias_method :inner_text, :content 136 alias_method :to_plain_text, :content 136 def to_s 137 Hpricot.uxs(@content) 138 end 139 alias_method :to_plain_text, :to_s 137 140 def output(out, opts = {}) 138 141 out <<
