generating webpages with Ruby... help with double quotes

Discussion in 'Ruby' started by Zoe Phoenix, Jul 18, 2008.

  1. Zoe Phoenix

    Zoe Phoenix Guest

    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/.
    Zoe Phoenix, Jul 18, 2008
    #1
    1. Advertising

  2. [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 <>
    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
    reuben doetsch, Jul 18, 2008
    #2
    1. Advertising

  3. Zoe Phoenix

    Tim Pease Guest

    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
    Tim Pease, Jul 18, 2008
    #3
  4. [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 <> (GoogleTalk:
    )
    If there's one thing that computers do well, it's to make the same
    mistake uncountable times at inhuman speed. (Peter Coffee)
    Michael T. Richter, Jul 18, 2008
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Chris White

    Quotes/Double Quotes in Image Control

    Chris White, Sep 22, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    4,843
    Hermit Dave
    Sep 22, 2004
  2. Chris
    Replies:
    1
    Views:
    13,626
    Oisin
    Mar 24, 2006
  3. Lawrence Tierney

    Multiline quotes - escaping quotes - et al

    Lawrence Tierney, Dec 24, 2003, in forum: Java
    Replies:
    3
    Views:
    4,488
    Andrew Thompson
    Dec 24, 2003
  4. Sydex
    Replies:
    12
    Views:
    6,471
    Victor Bazarov
    Feb 17, 2005
  5. jOhn
    Replies:
    1
    Views:
    218
    Phlip
    Jan 29, 2008
Loading...

Share This Page