Create HTML files using RUBY

Reply

Join Date: Oct 2009
Posts: 4
Reputation: skrithikaa is an unknown quantity at this point 
Solved Threads: 0
skrithikaa skrithikaa is offline Offline
Newbie Poster

Create HTML files using RUBY

 
0
  #1
20 Days Ago
Hi,

How do you create HTML files using RUBY. I have a requirement where I need to set color and font of the text, and also provide formatting options for tables having different colors for rows and border(on/off).

Can anybody tell how to do this

Thanks,
K
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 91
Reputation: thines01 is an unknown quantity at this point 
Solved Threads: 8
thines01 thines01 is offline Offline
Junior Poster in Training
 
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.

  1. fileHtml = File.new("fred.html", "w+")
  2. fileHtml.puts "<HTML><BODY BGCOLOR='green'>"
  3. fileHtml.puts "<CENTER>this is neat</CENTER>"
  4. fileHtml.puts "</BODY></HTML>"
  5. fileHtml.close()
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 91
Reputation: thines01 is an unknown quantity at this point 
Solved Threads: 8
thines01 thines01 is offline Offline
Junior Poster in Training
 
0
  #3
16 Days Ago
...here's a more robust example (with sloppy html):
  1.  
  2. fileHtml = File.new("fred.html", "w+")
  3. fileHtml.puts "<HTML><BODY BGCOLOR='green'>"
  4. fileHtml.puts "<CENTER>this is neat</CENTER><br>"
  5. fileHtml.puts "<CENTER><FONT COLOR='yellow'>this is neat</FONT></CENTER>"
  6.  
  7. fileHtml.puts "<TABLE BORDER='1' ALIGN='center'>"
  8. fileHtml.puts "<TR><TH>HEADER</TH></TR>"
  9. fileHtml.puts "<TR><TD>Cell in <FONT COLOR='RED'>TableThing</FONT></TD></TR>"
  10. fileHtml.puts "</TABLE>"
  11.  
  12. fileHtml.puts "<TABLE BORDER='0' ALIGN='center'>"
  13. fileHtml.puts "<TR><TH>HEADER on borderless</TH></TR>"
  14. fileHtml.puts "<TR><TD>Cell in borderless<FONT COLOR='white'>TableThing</FONT></TD></TR>"
  15. fileHtml.puts "</TABLE>"
  16. fileHtml.puts "</BODY></HTML>"
  17. fileHtml.close()
  18.  
  19. system("start fred.html") #...on windows
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 178
Reputation: codejoust is an unknown quantity at this point 
Solved Threads: 17
codejoust's Avatar
codejoust codejoust is offline Offline
Junior Poster
 
0
  #4
12 Days Ago
You also can use a (rather antiquidated, but included) cgi class.
The CGI class would be like
  1. #!/usr/bin/env ruby
  2. # *-ruby-*-
  3. require 'cgi'
  4.  
  5. # Create an instance of CGI, with HTML 4 output
  6. cgi = CGI.new("html4")
  7.  
  8. # Send the following to the CGI object's output
  9. cgi.out {
  10. cgi.html {
  11.  
  12. # Produce a header
  13. cgi.head { cgi.title { "This is a title" }
  14. } +
  15.  
  16. # Produce a body
  17. cgi.body {
  18. cgi.h1 { "This is a headline" } +
  19. cgi.p { "Hello, world." }
  20. }
  21. }
  22. }
Docs: http://ruby-doc.org/stdlib/libdoc/cgi/rdoc/index.html
If your looking for templating etc, try looking at haml-lang.org
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 4
Reputation: skrithikaa is an unknown quantity at this point 
Solved Threads: 0
skrithikaa skrithikaa is offline Offline
Newbie Poster

Create Api to create document and add, edit, delete text

 
0
  #5
11 Days Ago
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
Reply With Quote Quick reply to this message  
Reply

Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC