Created
April 14, 2009 16:16
-
-
Save kematzy/95260 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby -wKU | |
def form(name, attrs={},&block) | |
content = block.call if block_given? | |
"<form #{attrs.inspect}>#{content}</form>" | |
end | |
def textfield(name, attrs={}) | |
out = "<input type=\"text\" name=\"#{name}\"#{attrs.inspect}>" | |
end | |
def msg(msg) | |
msg | |
end | |
f = form('user',:id => "id", :action => "/users") do | |
textfield(:name, :label => "Name", :value => "This works?") | |
msg("this is the content") | |
end | |
p f | |
# p callcc {|cont| cont.call } # nil | |
# p callcc {|cont| cont.call 1 } # 1 | |
# p callcc {|cont| cont.call 1, 2, 3 } # => [1, 2, 3] | |
def block_catcher(&block) | |
block.call | |
end | |
block_catcher do | |
puts 'hello there' | |
puts 'Hi again' | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment