The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
Less method_missing in Markaby

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Red Handed

Posts: 1158
Nickname: redhanded
Registered: Dec, 2004

Red Handed is a Ruby-focused group blog.
Less method_missing in Markaby Posted: May 22, 2006 4:32 PM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Red Handed.
Original Post: Less method_missing in Markaby
Feed Title: RedHanded
Feed URL: http://redhanded.hobix.com/index.xml
Feed Description: sneaking Ruby through the system
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Red Handed
Latest Posts From RedHanded

Advertisement

In the new Markaby branch, I’ve got a list of valid tags and attributes generated from the XHTML 1.0 Transitional and XHTML 1.0 Strict DTDs. Which means Markaby can validate as you go.

 >> div :styl => 'margin:10px' do
 >> h1 "Never To Be Seen" 
 >> end
 Markaby::InvalidXhtmlError: no attribute `styl' on div elements
 >> salect :onclick => 'javascript:alert("GIMMICK!")' do
 >> option '- please -'
 >> end
 NoMethodError: no such method `salect'

However, there is no check right now to make sure that the nesting is right. It’ll let you put a tbody in a div, for example. But it’s a start.

The implicit stringification of tags and helpers is working fantastic now as well. Can ERB compete with this (from CampSh [103]):

 strong(author) + " worked on: " + 
 cmds.map { |cmd| 
 a cmd.name, :href => R(Show, cmd.name) }.join(", ")

There’s little need for the capture statement any longer. If you need to force a capture, call to_s on the HTML fragment.

 div { 
 @a = small('Miniature').to_s
 @b = strong('Large').to_s
 h1 "Monkeys" 
 h2 { "Giraffes #{@a} and #{@b}" }
 h3 "Donkeys" 
 h4 { "Parakeet #{@b} as well..." }
 }

It’s not needed in the above example, though, since the string interpolation will call to_s for you. Does that make sense?

Read: Less method_missing in Markaby

Topic: Testing Roundup Previous Topic   Next Topic Topic: Even Better Random Times for Rails

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use