|
View:
New views
20 Messages
—
Rating Filter:
Alert me
|
| < Prev | 1 - 2 | Next > |
|
|
Create HTML files using RUBYHi,
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 -- Posted via http://www.ruby-forum.com/. |
|
|
Re: Create HTML files using RUBYKrithika San wrote:
> 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 > Use a module such as Haml or ERb. If you need a full Web application, use one of the Ruby Web frameworks (Rails, Merb, Sinatra, Ramaze...). > Thanks, > K Best, -- Marnen Laibow-Koser http://www.marnen.org marnen@... -- Posted via http://www.ruby-forum.com/. |
|
|
Re: Create HTML files using RUBYHi Marnen,
Thanks for your suggestion. I purely have to use only RUBY. Does cgi script allows to do the below mentioned features? Thanks in advance, Krithika Marnen Laibow-Koser wrote: > Krithika San wrote: >> 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 >> > > Use a module such as Haml or ERb. If you need a full Web application, > use one of the Ruby Web frameworks (Rails, Merb, Sinatra, Ramaze...). > >> Thanks, >> K > > Best, > -- > Marnen Laibow-Koser > http://www.marnen.org > marnen@... -- Posted via http://www.ruby-forum.com/. |
|
|
Re: Create HTML files using RUBYKrithika San wrote:
> Hi Marnen, > > Thanks for your suggestion. I purely have to use only RUBY. Does cgi > script allows to do the below mentioned features? Everything I mentioned is only Ruby. Use it -- otherwise you'll be reinventing the wheel for no good reason. > > Thanks in advance, > Krithika Best, -- Marnen Laibow-Koser http://www.marnen.org marnen@... -- Posted via http://www.ruby-forum.com/. |
|
|
Re: Create HTML files using RUBYI am sorry I was not clear in my previous reply. I am told not to use
Rails or rather not implementing Web Framework. My previous project was to create elements like text and table, edit them in memory and then write them into a file. This is an extension of it where I need to provide HTML support. I need to provide options for changing the color of text, font change and then create tables with rows having diferent colors. Thanks, Krithika Marnen Laibow-Koser wrote: > Krithika San wrote: >> Hi Marnen, >> >> Thanks for your suggestion. I purely have to use only RUBY. Does cgi >> script allows to do the below mentioned features? > > Everything I mentioned is only Ruby. Use it -- otherwise you'll be > reinventing the wheel for no good reason. > >> >> Thanks in advance, >> Krithika > > Best, > -- > Marnen Laibow-Koser > http://www.marnen.org > marnen@... -- Posted via http://www.ruby-forum.com/. |
|
|
Re: Create HTML files using RUBYKrithika San wrote:
> I am sorry I was not clear in my previous reply. I am told not to use > Rails or rather not implementing Web Framework. So don't use a Web framework. Haml and ERb can both work on their own. > > My previous project was to create elements like text and table, edit > them in memory and then write them into a file. This is an extension of > it where I need to provide HTML support. > I need to provide options for changing the color of text, font change > and then create tables with rows having diferent colors. > Use one of the libraries I mentioned above. > Thanks, > Krithika > Best, -- Marnen Laibow-Koser http://www.marnen.org marnen@... -- Posted via http://www.ruby-forum.com/. |
|
|
Re: Create HTML files using RUBYOn Wed, Nov 4, 2009 at 9:40 PM, Marnen Laibow-Koser <marnen@...> wrote:
> Krithika San wrote: >> I am sorry I was not clear in my previous reply. I am told not to use >> Rails or rather not implementing Web Framework. > > So don't use a Web framework. Haml and ERb can both work on their own. As a clarifying point for the OP, ERb is part of standard Ruby. It is not a third party library. (Which is not the case with Haml) But FWIW, Haml can easily be vendored, so you can probably sneak it in just as easily. -greg |
|
|
Re: Create HTML files using RUBY> How do you create HTML files using RUBY.
A html file is nothing else than a long string. You can generate that string via any language easily. Or you could use something "ready-made" like cgi or the template engines suggested above. I really am not sure where the problem is because a .html file is nothing than a big string... -- Posted via http://www.ruby-forum.com/. |
|
|
Re: Create HTML files using RUBYI challenge that statement
You can generate that string via any language easily. Or you could use something "ready-made" like cgi or the template engines suggested above. have a look at this language http://en.wikipedia.org/wiki/Brainfuck |
|
|
Re: Create HTML files using RUBYOn Wed, Nov 4, 2009 at 10:45 PM, William Manire
<williamkmanire@...> wrote: > have a look at this language > > http://en.wikipedia.org/wiki/Brainfuck Brainfuck is Turing complete, so it can do anything Ruby can do. As for making it easier... just compile whatever higher level language you'd like down to Brainfuck. Or is that cheating? :) -greg |
|
|
Re: Create HTML files using RUBYKrithika San wrote:
> 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 If I was going to write this myself I'd try something like: def h1 print "<H1>" yield print "</H1>" end h1 do print "I'm a heading!" end => <H1>I'm a heading!</h1> By yielding to the block you allow yourself to nest other tags inside of tags which is something you often have to do when writing html. Good luck. -- Posted via http://www.ruby-forum.com/. |
|
|
Re: Create HTML files using RUBYGreg Barozzi wrote:
[...] > If I was going to write this myself I'd try something like: > > def h1 > print "<H1>" > yield > print "</H1>" > end > > h1 do > print "I'm a heading!" > end > > => <H1>I'm a heading!</h1> > > > By yielding to the block you allow yourself to nest other tags > inside of tags which is something you often have to do when writing > html. > > Good luck. Good point. This is the approach that Builder and Markaby take. In Web apps, I prefer my markup not to look like Ruby, but in a situation like that of the OP, Builder might be useful. Best, -- Marnen Laibow-Koser http://www.marnen.org marnen@... -- Posted via http://www.ruby-forum.com/. |
|
|
Re: Create HTML files using RUBYKrithika San wrote:
> I am sorry I was not clear in my previous reply. I am told not to use > Rails or rather not implementing Web Framework. > > My previous project was to create elements like text and table, edit > them in memory and then write them into a file. This is an extension of > it where I need to provide HTML support. > I need to provide options for changing the color of text, font change > and then create tables with rows having diferent colors. > > Thanks, > Krithika > What you are trying to do is still unclear to me, but the CGI library included with Ruby probably does what you need, if you are not allowed to use any external libraries. http://ruby-doc.org/stdlib/libdoc/cgi/rdoc/classes/CGI/HtmlExtension.html -Justin |
|
|
Re: Create HTML files using RUBYYou've gotta remember all of the attributes and stuff to properly support
CSS and the standard. You have to decide what standard you want to implement. HTML X.X, XHTML etc... w3schools is an awesome site that has a lot of information about the standards, but I would also check out the RFCs. Also remember that some of the standards seem to be universally ignored by all (or most) and you'll have to deal with related maintenance issues as a result :) Good luck 2009/11/4 Marnen Laibow-Koser <marnen@...> > Greg Barozzi wrote: > [...] > > If I was going to write this myself I'd try something like: > > > > def h1 > > print "<H1>" > > yield > > print "</H1>" > > end > > > > h1 do > > print "I'm a heading!" > > end > > > > => <H1>I'm a heading!</h1> > > > > > > By yielding to the block you allow yourself to nest other tags > > inside of tags which is something you often have to do when writing > > html. > > > > Good luck. > > Good point. This is the approach that Builder and Markaby take. In Web > apps, I prefer my markup not to look like Ruby, but in a situation like > that of the OP, Builder might be useful. > > Best, > -- > Marnen Laibow-Koser > http://www.marnen.org > marnen@... > > -- > Posted via http://www.ruby-forum.com/. > > -- William Kevin Manire Lead Developer Edge Of Nowhere LLC (http://www.edgeofnowherellc.com) (206) 384-5826 |
|
|
Re: Create HTML files using RUBYOn Thu, 05 Nov 2009 12:31:43 +0900, Gregory Brown wrote:
> But FWIW, Haml can easily be vendored, so you can probably sneak it in > just as easily. > > -greg Umm only if you're allowed to use a framework that supports "vendoring" (whatever that is). -- Chanoch (Ken) Bloom. PhD candidate. Linguistic Cognition Laboratory. Department of Computer Science. Illinois Institute of Technology. http://www.iit.edu/~kbloom1/ |
|
|
Re: Create HTML files using RUBY> If I was going to write this myself I'd try something like: > > def h1 > print "<H1>" > yield > print "</H1>" > end > > h1 do > print "I'm a heading!" > end > > => <H1>I'm a heading!</h1> > > > By yielding to the block you allow yourself to nest other tags > inside of tags which is something you often have to do when writing > html. > > Good luck. That's nice. I suggest that if the OP wants to use your suggested method, maybe do it this way: class MyHtml def self.generate(&block) "<html>\n" + self.new.instance_eval(&block) + "\n</html>" end def body "<body>\n#{ yield }\n</body>" end def h1 "<h1>#{ yield }</h1>" end end MyHtml.generate do body do h1 { "This heading was generated by pure ruby" } end end Or just use builder or something :P (though it seems like that just might not be allowed for the OP, as I suspect whoever is assigning this work expects a real html generator implementation. - Ehsan _________________________________________________________________ Hotmail: Trusted email with powerful SPAM protection. http://clk.atdmt.com/GBL/go/177141665/direct/01/ |
|
|
Re: Create HTML files using RUBY> > But FWIW, Haml can easily be vendored, so you can probably sneak it in > > just as easily. > > > > -greg > > Umm only if you're allowed to use a framework that supports > "vendoring" (whatever that is). Errr, that has nothing to do with the framework. Vendoring just means including the entire source as part of your project, instead of assuming the environment will have it set up (through rubygems or whatever). If you're using rubygems, as almost everyone, just use the "gem unpack haml" in your application if you want to vendor haml. Then you just add "require 'haml/lib/haml'" or whatever the path is to your application. No framework required. Without rubygems, just copy the source in, easy enough. _________________________________________________________________ Bing brings you maps, menus, and reviews organized in one place. http://www.bing.com/search?q=restaurants&form=MFESRP&publ=WLHMTAG&crea=TEXT_MFESRP_Local_MapsMenu_Resturants_1x1 |
|
|
Re: Create HTML files using RUBYOn Thu, Nov 5, 2009 at 12:08 AM, Ken Bloom <kbloom@...> wrote:
> On Thu, 05 Nov 2009 12:31:43 +0900, Gregory Brown wrote: > >> But FWIW, Haml can easily be vendored, so you can probably sneak it in >> just as easily. >> >> -greg > > Umm only if you're allowed to use a framework that supports > "vendoring" (whatever that is). All it means is packaging someone elses source with yours and adding it somewhere in the loadpath. No framework needed. |
|
|
Re: Create HTML files using RUBYOn Nov 5, 1:39 am, Gregory Brown <gregory.t.br...@...> wrote:
> On Thu, Nov 5, 2009 at 12:08 AM, Ken Bloom <kbl...@...> wrote: > > On Thu, 05 Nov 2009 12:31:43 +0900, Gregory Brown wrote: > > >> But FWIW, Haml can easily be vendored, so you can probably sneak it in > >> just as easily. > > >> -greg > > > Umm only if you're allowed to use a framework that supports > > "vendoring" (whatever that is). > > All it means is packaging someone elses source with yours and adding > it somewhere in the loadpath. No framework needed. I don't think the OP said he couldn't use frameworks. I think he can't use a *web* framework, probably because he wants something more lightweight. I second the HAML or ERb suggestion. http://haml-lang.com/ David |
|
|
Re: Create HTML files using RUBYI am told to create static HTML page and asked to write something like
what Marnen has quoted. External library and CGI script are also not required to use. So let me try what Marnen has mentioned. Could you tell me if I can do something like this file_html = File.new("sample.html", "w+") file_html.puts "<HTML><BODY BGCOLOR='green'>" file_html.puts "<CENTER>This is a color</CENTER><br>" file_html.puts "<CENTER><FONT COLOR='yellow'>This is yellowww</FONT></CENTER>" file_html.puts "</BODY></HTML>" file_html.close() system("start sample.html") Thanks, Krithika Justin Collins wrote: > Krithika San wrote: >> Krithika >> > > What you are trying to do is still unclear to me, but the CGI library > included with Ruby probably does what you need, if you are not allowed > to use any external libraries. > > http://ruby-doc.org/stdlib/libdoc/cgi/rdoc/classes/CGI/HtmlExtension.html > > -Justin -- Posted via http://www.ruby-forum.com/. |
| < Prev | 1 - 2 | Next > |
| Free embeddable forum powered by Nabble | Forum Help |