[#3006] mismatched quotation — "stevan apter" <apter@...>

ruby documentation uses a punctuation convention i've never seen

13 messages 2000/05/27

[ruby-talk:02665] Re: win OLE / eRuby

From: OZAWA Sakuro <crouton@...>
Date: 2000-05-09 15:05:36 UTC
List: ruby-talk #2665
At Tue, 09 May 2000 23:36:48 +0900,
OZAWA Sakuro <crouton@duelists.org> wrote:

> > Could you say why <%=variable%> is necessary instead of <%variable%>?
> <%=foo%> is short form of <%print foo%>

Let me add a small explanation.

What eRuby does is simple.
It replaces all occurances of text to "print" method invocation, except
those inside <% and %> which is replaced with the content itself.

So

  <%the_name = "matz"%>
  <%5.times do%>
    Hello, <%print the_name%>!
  <%end%>

whould yields to

  the_name = "matz"
  5.times do
    print "Hello, "; print the_name; print "!";
  end

<%=...%> pair is shorthand of <%print ...%>, so you can write the above
like this.

  <%the_name = "matz"%>
  <%5.times do%>
    Hello, <%=the_name%>!
  <%end%>

Oh, eRuby can interpret another notation <%# foo %>, too.
Of cource, this is comment and ignored by eRuby:-)

-- 
OZAWA -Crouton- Sakuro
E-Mail: mailto:crouton@duelists.org
        mailto:crouton@isoternet.org
   Web: http://www.duelists.org/~crouton/
   PGP: C98F 74E0 AEEB 4578 1DFC  F650 3BE0 9627 11FC C9F5

In This Thread