while loop in a here documents

Discussion in 'Ruby' started by equinox, Dec 2, 2008.

  1. equinox

    equinox Guest

    I have a here documents of something like this:

    form = <<"DONE"

    while( bla ..bla .. bla) do



    How can I do a while loop inside a here documents in ruby? Is it
    equinox, Dec 2, 2008
    1. Advertisements

  2. equinox

    equinox Guest

    I am not using erb unfortunately, anyway to go around this?
    equinox, Dec 2, 2008
    1. Advertisements

  3. equinox

    Ken Bloom Guest

    No. You'll have to put the loop outside the string.
    Ken Bloom, Dec 2, 2008
  4. [Note: parts of this message were removed to make it a legal post.]

    Something like this? Though this has other problems...
    STDOUT.sync = true
    my_text = <<-FINISHED
    Note the sequence of when these things are written.
    #{3.times do
    puts "Hello"
    } times a greeting was written.
    end of my text
    puts my_text
    Victor H. Goff III, Dec 2, 2008
  5. What exactly are you trying to achieve? Do you want to have repeated
    content from the here doc?

    Robert Klemme, Dec 2, 2008
    1. Advertisements

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.