Skip to content

Instantly share code, notes, and snippets.

@JGallardo
Created December 14, 2012 03:42
Show Gist options
  • Save JGallardo/4282555 to your computer and use it in GitHub Desktop.
Save JGallardo/4282555 to your computer and use it in GitHub Desktop.
Ruby script to generate a form
require 'cgi'
cgi = CGI.new("html4Tr")
print "Enter Form Page Title: "
title = gets.chomp
print "Enter Head Title: "
input_title = gets.chomp
print "Enter value for button: "
value = gets.chomp
print "Enter group: "
group = gets.chomp
$stdout = File.new("form.html", "w")
cgi.out{
CGI.pretty(
cgi.html{
cgi.head{ "\n"+cgi.title{title}}+
cgi.body{"\n" +
cgi.form{"\n" +
cgi.hr +
cgi.h1 { "#{input_title}:" } + "\n" +
cgi.br +
cgi.checkbox(group, value) + value + cgi.br
cgi.br +
cgi.textarea("input",80,5) + "\n" +
cgi.br +
cgi.submit("Send")
}
}
}
)
}
$stdout.close
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment