Forum: Ruby Props - Nokogiri's Builder notation has class and ID shortcuts

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Aafa8848c4b764f080b1b31a51eab73d?d=identicon&s=25 Phlip (Guest)
on 2009-03-24 13:16
(Received via mailing list)
Rubies:

This is just a note to document a nice discovery in Nokogiri's tests:

         builder = Nokogiri::HTML::Builder.new do
           div.rad.thing! {
             text "<awesome>"
             b "hello"
           }
         end
         assert_equal(
           '<div class="rad"
id="thing">&lt;awesome&gt;<b>hello</b></div>',
                      builder.doc.root.to_html.gsub(/\n/, ''))

The Builder notation div.rad.thing! expanded to <div class="rad"
id="thing">.
This implies .rad, without a bang, expands to class="rad", and .thing!,
with the
bang, expands to an ID.

(-8
This topic is locked and can not be replied to.