Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save kematzy/95260 to your computer and use it in GitHub Desktop.
Save kematzy/95260 to your computer and use it in GitHub Desktop.
#!/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