[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

generating webpages with Ruby... help with double quotes

Zoe Phoenix

7/18/2008 3:09:00 AM

I want a program that I'm working on to generate some web pages for me,
but I'm having trouble with generating the pages in HTML, since it uses
the double quotes for links, as in <a
href="http://www.blahblahblah.com">....

Since there are a lot of the links in this page, I need to know what the
best way to get around this problem is. Can someone help me, please?
--
Posted via http://www.ruby-....

3 Answers

reuben doetsch

7/18/2008 3:47:00 AM

0

[Note: parts of this message were removed to make it a legal post.]

You can just use single quotes. So
string= '<a href="http://www.blahblahblah.com"></a...

On Thu, Jul 17, 2008 at 10:09 PM, Zoe Phoenix <dark_sgtphoenix@hotmail.com>
wrote:

> I want a program that I'm working on to generate some web pages for me,
> but I'm having trouble with generating the pages in HTML, since it uses
> the double quotes for links, as in <a
> href="http://www.blahblahblah.com">....
>
> Since there are a lot of the links in this page, I need to know what the
> best way to get around this problem is. Can someone help me, please?
> --
> Posted via http://www.ruby-....
>

Reuben Doetsch

Tim Pease

7/18/2008 4:09:00 AM

0

On Jul 17, 2008, at 9:09 PM, Zoe Phoenix wrote:

> I want a program that I'm working on to generate some web pages for
> me,
> but I'm having trouble with generating the pages in HTML, since it
> uses
> the double quotes for links, as in <a
> href="http://www.blahblahblah.com">....
>
> Since there are a lot of the links in this page, I need to know what
> the
> best way to get around this problem is. Can someone help me, please?

The are a few different ways to construct your HTML output:


%q(<p>your html <a href="http://foo.example.com">code... goes here)

%Q(<p>just another form that supports #{variable} expansion)

<<-HTML
<body>
<p>and the big daddy of them all -- the <em>heredoc</em> format</p>

<p>this will create a single string from the all the text found
between the opening <code><<-HTML</code> marker above and the closing
<code>HTML</code> marker below<p>

<p>you can use any uppercase string to mark your heredoc</p>

<p>heredocs also support #{variable} substitution</p>

<div id="foot">
<p>hope that helps</p>

<p>Blessings,<br />
TwP</p>
HTML


Michael T. Richter

7/18/2008 5:22:00 AM

0

[Note: parts of this message were removed to make it a legal post.]

On Fri, 2008-07-18 at 12:09 +0900, Zoe Phoenix wrote:

> I want a program that I'm working on to generate some web pages for me,
> but I'm having trouble with generating the pages in HTML, since it uses
> the double quotes for links, as in <a
> href="http://www.blahbl...">....



> Since there are a lot of the links in this page, I need to know what the
> best way to get around this problem is. Can someone help me, please?


Strings have a large number of different representations for precisely
this reason:


"<a href=\"http://www.blahbl...\">" # double-quoted strings do interpolation and have a lot of \-escapes.
'<a href="http://www.blahbl...">' # single-quoted strings don't do interpolation and only \-escape \ and '.
%q{<a href="http://www.blahbl...">} # same as a single-quoted string, but ' isn't special
%q|<a href="http://www.blahbl...">| # the delimiter doesn't have to be braces
%Q{<a href="http://www.blahbl...">} # same as double-quoted-string, but " isn't special


Then there's "here documents" and the like, and there's other variants
of these in the facets gem. Pick and choose the representation that
suits your needs best. (In your case I'd likely recommend %Q{string
here}, %Q(string here) or even %Q|string here|.)


--
Michael T. Richter <ttmrichter@gmail.com> (GoogleTalk:
ttmrichter@gmail.com)
If there's one thing that computers do well, it's to make the same
mistake uncountable times at inhuman speed. (Peter Coffee)