Erb rdoc wrong?

Discussion in 'Ruby' started by Belorion, Feb 18, 2006.

  1. Belorion

    Belorion Guest

    ------=_Part_8007_16432951.1140285180549
    Content-Type: text/plain; charset=ISO-8859-1
    Content-Transfer-Encoding: quoted-printable
    Content-Disposition: inline

    Greetings.

    I am trying to use Erb to process a plain-text template. Following the RDo=
    c
    documentation at
    http://www.ruby-doc.org/stdlib/libdoc/erb/rdoc/classes/ERB.html, I can't ge=
    t
    the first plain-text example to work. ruby 1.8.2 (2004-12-25)
    [i686-linux]. Below[1] is the actual sample script which isn't working
    (it's not finding the local variables when processing the template). Any
    ideas what's going on here? Thanks.

    -Matt

    [1]
    require "erb"

    # Create template.
    template =3D %q{
    From: James Edward Gray II <>
    To: <%=3D to %>
    Subject: Addressing Needs

    <%=3D to[/\w+/] %>:

    Just wanted to send a quick note assuring that your needs are being
    addressed.

    I want you to know that my team will keep working on the issues,
    especially:

    <%# ignore numerous minor requests -- focus on priorities %>
    % priorities.each do |priority|
    * <%=3D priority %>
    % end

    Thanks for your patience.

    James Edward Gray II
    }.gsub(/^ /, '')

    message =3D ERB.new(template, 0, "%<>")

    # Set up template data.
    to =3D "Community Spokesman <spokesman@ruby_community.org>"
    priorities =3D [ "Run Ruby Quiz",
    "Document Modules",
    "Answer Questions on Ruby Talk" ]

    # Produce result.
    email =3D message.result
    puts email

    ------=_Part_8007_16432951.1140285180549--
     
    Belorion, Feb 18, 2006
    #1
    1. Advertising

  2. On Feb 18, 2006, at 11:53 AM, Belorion wrote:

    > Any ideas what's going on here?


    Hmm, has ERB stopped defaulting to a top-level binding?

    > email = message.result


    Change that to:

    email = message.result(binding)

    Can someone please patch the docs for me?

    James Edward Gray II
     
    James Edward Gray II, Feb 18, 2006
    #2
    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. Andreas Schwarz
    Replies:
    6
    Views:
    254
    Randy W. Sims
    Jan 1, 2004
  2. Brian Schröder
    Replies:
    5
    Views:
    141
    Dave Thomas
    Sep 18, 2004
  3. Daniel Berger
    Replies:
    1
    Views:
    144
    Dave Thomas
    Nov 2, 2004
  4. Steve V
    Replies:
    6
    Views:
    238
    Steve V
    Apr 20, 2005
  5. Dan Thomas

    link to .erb file, from .erb file

    Dan Thomas, Jan 26, 2011, in forum: Ruby
    Replies:
    4
    Views:
    167
    Dan Thomas
    Jan 26, 2011
Loading...

Share This Page