[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

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

Phlip

3/24/2009 12:12:00 PM

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

--
Phlip