| | |
Create HTML files using RUBY
Please support our Ruby advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Oct 2009
Posts: 91
Reputation:
Solved Threads: 8
0
#2 16 Days Ago
There's really nothing special other than just outputting HTML syntax inside of a file named with an htm or html extension.
Ruby Syntax (Toggle Plain Text)
fileHtml = File.new("fred.html", "w+") fileHtml.puts "<HTML><BODY BGCOLOR='green'>" fileHtml.puts "<CENTER>this is neat</CENTER>" fileHtml.puts "</BODY></HTML>" fileHtml.close()
•
•
Join Date: Oct 2009
Posts: 91
Reputation:
Solved Threads: 8
0
#3 16 Days Ago
...here's a more robust example (with sloppy html):
Ruby Syntax (Toggle Plain Text)
fileHtml = File.new("fred.html", "w+") fileHtml.puts "<HTML><BODY BGCOLOR='green'>" fileHtml.puts "<CENTER>this is neat</CENTER><br>" fileHtml.puts "<CENTER><FONT COLOR='yellow'>this is neat</FONT></CENTER>" fileHtml.puts "<TABLE BORDER='1' ALIGN='center'>" fileHtml.puts "<TR><TH>HEADER</TH></TR>" fileHtml.puts "<TR><TD>Cell in <FONT COLOR='RED'>TableThing</FONT></TD></TR>" fileHtml.puts "</TABLE>" fileHtml.puts "<TABLE BORDER='0' ALIGN='center'>" fileHtml.puts "<TR><TH>HEADER on borderless</TH></TR>" fileHtml.puts "<TR><TD>Cell in borderless<FONT COLOR='white'>TableThing</FONT></TD></TR>" fileHtml.puts "</TABLE>" fileHtml.puts "</BODY></HTML>" fileHtml.close() system("start fred.html") #...on windows
0
#4 12 Days Ago
You also can use a (rather antiquidated, but included) cgi class.
The CGI class would be like
Docs: http://ruby-doc.org/stdlib/libdoc/cgi/rdoc/index.html
If your looking for templating etc, try looking at haml-lang.org
The CGI class would be like
ruby Syntax (Toggle Plain Text)
#!/usr/bin/env ruby # *-ruby-*- require 'cgi' # Create an instance of CGI, with HTML 4 output cgi = CGI.new("html4") # Send the following to the CGI object's output cgi.out { cgi.html { # Produce a header cgi.head { cgi.title { "This is a title" } } + # Produce a body cgi.body { cgi.h1 { "This is a headline" } + cgi.p { "Hello, world." } } } }
If your looking for templating etc, try looking at haml-lang.org
CodeJoust! Design + Development - Proud User of Ubuntu
•
•
Join Date: Oct 2009
Posts: 4
Reputation:
Solved Threads: 0
Sub: Create Api to create document and add, edit, delete text and
table(add row, modify and delete row)
Can somebody please tell me how to implement this using inheritence /
composition / patterns ?
Thanks,
skrithikaa Sub: Create Api to create document and add, edit, delete text and
table(add row, modify and delete row)
Can somebody please tell me how to implement this using inheritence /
composition / patterns ?
Thanks,
skrithikaa
table(add row, modify and delete row)
Can somebody please tell me how to implement this using inheritence /
composition / patterns ?
Thanks,
skrithikaa Sub: Create Api to create document and add, edit, delete text and
table(add row, modify and delete row)
Can somebody please tell me how to implement this using inheritence /
composition / patterns ?
Thanks,
skrithikaa
![]() |
Similar Threads
- create html file from rss feed (PHP)
- Help get me started, create multiple files from list (Shell Scripting)
- Need help to padding the word to create flat files (Shell Scripting)
- How to create set of files. (C++)
- Create HTML Table with Dynamic Rows (PHP)
- Using VBScript to read multiple HTML files (Visual Basic 4 / 5 / 6)
- Using VBScript to manage HTML files (Visual Basic 4 / 5 / 6)
- Is MAC OS capable of opening HTML files? (Mac Software)
- open html files in jar (Java)
Other Threads in the Ruby Forum
- Previous Thread: (Installed Ruby 1.9.1) gem isn't working
- Next Thread: Meaning of '!(...' EG: "myObject.parse!(argv)" ..?
| Thread Tools | Search this Thread |





