> I think people who don't want to write HTML in HTML should write it in
> something they prefer.
i like to write HTML in Ruby, {attr: :val} for elements, [] for lists of
elements, and "" for..strings
def H _
case _
when Hash then
'<'+(_[:_]||:div).to_s+(_.keys-[:_,:c]).map{|a|
' '+a.to_s+'='+"'"+
_[a].to_s.hsub({"'"=>'%27',
'>'=>'%3E',
'<'=>'%3C'})+"'"}.join+'>'+
(_[:c] ? (H _[:c]) : '')+
'</'+(_[:_]||:div).to_s+'>'
when Array then
_.map{|n|H n}.join
else
_.to_s
end
end
irb(main):010:0> H [{style: "display:block", c: {_: :h1, c:
"TESTING"}},(0..3).map{|i|"#{i}.."}]
=> "<div style='display:block'><h1>TESTING</h1></div>0..1..2..3.."
_______________________________________________
Camping-list mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/camping-list