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


#1

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”><awesome>hello’,
builder.doc.root.to_html.gsub(/\n/, ‘’))

The Builder notation div.rad.thing! expanded to

.
This implies .rad, without a bang, expands to class=“rad”, and .thing!,
with the
bang, expands to an ID.

(-8