vendor/osx/gems/hpricot-0.5/lib/hpricot/elements.rb
# Wraps each element in the list inside the element created by HTML +str+. 
# If more than one element is found in the string, Hpricot locates the
# deepest spot inside the first element.
#
#  doc.search("a[@href]").
#      wrap(%{<div class="link"><div class="link_inner"></div></div>})
#
# This code wraps every link on the page inside a +div.link+ and a +div.link_inner+ nest.
Wraps each element in the list inside the element created by HTML +str+.
If more than one element is found in the string, Hpricot locates the
deepest spot inside the first element.



This code wraps every link on the page inside a +div.link+ and a +div.link_inner+ nest.
Wraps each element in the list inside the element created by HTML + str + . If more than one element is found in the string Hpricot locates the deepest spot inside the first element . This code wraps every link on the page inside a + div . link + and a + div . link_inner + nest .
def wrap(str)
      each do |x|
        wrap = Hpricot.make(str)
        nest = wrap.detect { |w| w.respond_to? :children }
        unless nest
          raise Exception, "No wrapping element found."
        end
        x.parent.replace_child(x, wrap)
        nest = nest.children.first until nest.empty?
        nest.children << x
      end
    end
def wrap ( str ) each do | x | wrap = Hpricot . make ( str ) nest = wrap . detect { | w | w . respond_to? :children } unless nest raise Exception , "No wrapping element found." end x . parent . replace_child ( x , wrap ) nest = nest . children . first until nest . empty? nest . children << x end end
Wraps each element in the list inside the element created by HTML +str+.
Wraps each element in the list inside the element created by HTML + str + .
str
<not_specific>