Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > generating webpages with Ruby... help with double quotes

Reply
Thread Tools

generating webpages with Ruby... help with double quotes

 
 
Zoe Phoenix
Guest
Posts: n/a
 
      07-18-2008
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"></a>.

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/.

 
Reply With Quote
 
 
 
 
reuben doetsch
Guest
Posts: n/a
 
      07-18-2008
[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 <(E-Mail Removed)>
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"></a>.
>
> 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

 
Reply With Quote
 
 
 
 
Tim Pease
Guest
Posts: n/a
 
      07-18-2008
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"></a>.
>
> 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</a> 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


 
Reply With Quote
 
Michael T. Richter
Guest
Posts: n/a
 
      07-18-2008
[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.blahblahblah.com"></a>.




> 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.
'<a href="http://www.blahblahblah.com">' # single-quoted strings don't do interpolation and only \-escape \ and '.
%q{<a href="http://www.blahblahblah.com">} # same as a single-quoted string, but ' isn't special
%q|<a href="http://www.blahblahblah.com">| # the delimiter doesn't have to be braces
%Q{<a href="http://www.blahblahblah.com">} # 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 <(E-Mail Removed)> (GoogleTalk:
http://www.velocityreviews.com/forums/(E-Mail Removed))
If there's one thing that computers do well, it's to make the same
mistake uncountable times at inhuman speed. (Peter Coffee)

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
regex to avoid escaped quotes or double quotes jOhn Ruby 1 01-29-2008 08:31 PM
PHP double quotes inside double quotes MSB Computer Support 11 10-21-2006 01:09 PM
Asp.NET Javascript string, want to pass '(single quotes' within '(single quotes) Chris ASP .Net 1 03-24-2006 09:03 PM
cannot convert parameter from 'double (double)' to 'double (__cdecl *)(double)' error Sydex C++ 12 02-17-2005 06:30 PM
Quotes/Double Quotes in Image Control Chris White ASP .Net 1 09-22-2004 06:22 AM



Advertisments