Arc Forumnew | comments | leaders | submitlogin
2 points by larry_h 6170 days ago | link | parent

When in ruby using Pannonica (a component based framework):

  class ArcChallenge < Pan::Task                                                               
    def go                                                                                     
      msg = call Input.new                                                                     
      call ClickHere.new                                                                       
      call YouSaid.new(msg)                                                                    
    end                                                                                        
  end

  class Input < Pan::Component                                                                 
    def render_on(html)                                                                        
      html.form {                                                                              
        html.input                                                                             
        html.submit {|val| answer(val)}                                                        
      }                                                                                        
    end                                                                                        
  end

  class ClickHere < Pan::Component                                                             
    def render_on(html)                                                                        
      html.link("Click here") { answer }                                                       
    end                                                                                        
  end

  class YouSaid < Pan::Component                                                               
    def initialize(msg)                                                                        
      @msg = msg                                                                               
    end                                                                                        
    def render_on(html)                                                                        
      html.lit("you said: #{@msg}")                                                            
    end                                                                                        
  end
It is worth noting the use of the seaside-like continuation based task construct.

Though not as tight as mr. Grahams code it does not lack in clarity IMHO.