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 .
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?
You can just use single quotes. So
string= ‘.’
On Thu, Jul 17, 2008 at 10:09 PM, Zoe P.
[email protected]
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 .
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-forum.com/.
Reuben Doetsch
On Jul 17, 2008, at 9:09 PM, Zoe P. 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 .
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(
your html code goes here)
%Q(
just another form that supports #{variable} expansion)
<<-HTML
and the big daddy of them all -- the heredoc format
this will create a single string from the all the text found
between the opening <<-HTML marker above and the closing
HTML marker below
you can use any uppercase string to mark your heredoc
heredocs also support #{variable} substitution
hope that helps
Blessings,
TwP
HTML
On Fri, 2008-07-18 at 12:09 +0900, Zoe P. 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 .
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.blahblahblah.com\">" # double-quoted
strings do interpolation and have a lot of -escapes.
‘’ # single-quoted
strings don’t do interpolation and only -escape \ and '.
%q{} # same as a
single-quoted string, but ’ isn’t special
%q|| # the delimiter
doesn’t have to be braces
%Q{} # 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|.)