Ah, yes, on p. 21 it says that <%= will execute the Ruby, HTML-escape
it, convert it to a string and print it to the screen. Unfortunately,
just because I read something doesn't mean I remember it! Thanks to
Walter and Hassan for reminding me!
Barney
On Jul 25, 8:42 pm, Walter Lee Davis <[email protected]> wrote:
> It's pretty basic:
>
> <%= foo %> means print whatever is inside to the output. In Rails 2.3,
> it means literally print it whatever it is. In Rails 3 and up, it
> means html-escape it and print it.
>
> <% foo %> means this is an instruction line, a bit of Ruby mixed in
> among the HTML. You use this to start and end your loops over a
> collection, or put an island of logic or data in the view. If you put
> a puts command in there, then it's functionally the same thing as the
> first one, but if you don't explicitly print anything, it's just a
> program step.
>
> <%- foo -%> means this is an instruction line, but in addition, don't
> leave an extra line of whitespace where it was, just do the Ruby
> instruction and don't add any whitespace.
>
> Walter
>
> On Jul 25, 2011, at 8:30 PM, Hassan Schroeder wrote:
>
> > On Mon, Jul 25, 2011 at 5:24 PM, Barney <[email protected]> wrote:
> >> Do you have a link where I can read about the differences between <
> >> %= ... , <%-... and <% ? I haven't spotted that in the "Agile Web
> >> Development with Rails" book I'm reading.
>
> > Look in the index for "ERb" -- my old second edition covers this on
> > page 40-43.
>
> > HTH,
> > --
> > Hassan Schroeder ------------------------ [email protected]
> >http://about.me/hassanschroeder
> > twitter: @hassan
>
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Ruby on Rails: Talk" group.
> > To post to this group, send email to rubyonrails-
> > [email protected].
> > To unsubscribe from this group, send email to
> > [email protected]
> > .
> > For more options, visit this group
> > athttp://groups.google.com/group/rubyonrails-talk?hl=en
> > .
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.