Erb reference anywhere online?

I have “Ruby for Rails” coming in in a few days, but in the meantime,
is there a good online ref for erb? I haven’t been able to find one.

Thanks,
Ken

Kenneth McDonald wrote:

I have “Ruby for Rails” coming in in a few days, but in the meantime,
is there a good online ref for erb? I haven’t been able to find one.

http://www.ruby-doc.org/stdlib/libdoc/erb/rdoc/

Also, the documentation for erubis (a better, faster implementation of
erb) is pretty good. Since they implement the same base feature set,
this should help you.
http://www.kuwata-lab.com/erubis/users-guide.html

To be honest, there’s nothing much you need to know about erb in Rails.

<% if foo %>

<% end %>

<%= some_expression %>

<%=h some_expression_which_needs_html_escaping %>

On Thu, Sep 25, 2008 at 05:14:00AM +0900, Brian C. wrote:

To be honest, there’s nothing much you need to know about erb in Rails.

<% if foo %>

<% end %>

<%= some_expression %>

<%=h some_expression_which_needs_html_escaping %>

True. What’s really needed is some guidelines for getting things done
with erb/erubis/etc., rather than documentation, for the most part –
such as how to solve some common problems people might encounter
migrating from a PHP way of doing things to an erb way of doing things.

Greater visibility of certain documentation matters might be nice, too,
like all the default path and custom path definition stuff that goes on
when working with an erb implementation.

Maybe, some day, I’ll get around to writing up some of that stuff
myself,
but ideally someone else would do it so it’d exist sooner than the
apocalypse.

True. What’s really needed is some guidelines for getting things done
with erb/erubis/etc., rather than documentation, for the most part –
such as how to solve some common problems people might encounter
migrating from a PHP way of doing things to an erb way of doing things.

Greater visibility of certain documentation matters might be nice, too,
like all the default path and custom path definition stuff that goes on
when working with an erb implementation.

Perhaps then you’re talking more about Rails and ActionPack (e.g. how
Rails locates a template, or how to factor code out into helper methods)
rather than Erb itself.

I found the book “Agile Web D. with Rails” to be extremely
good. Don’t buy the 2nd edition - the 3rd edition for Rails 2.x is under
development. However you can buy the 3rd edition beta PDF now, and get
free updates until the final release.

Otherwise, the Rails API documentation is pretty comprehensive.
http://api.rubyonrails.com/
Click on actionpack/README in the top left box for an overview; then
click on ActionView::Base in the middle left box. (Unfortunately the
“Learn more” link under “Embedded Ruby for templates” appears to be
broken)

If you install Rails on your machine (“gem install -y rails”), then run
“gem server --daemon”, you can point a web browser at
http://localhost:8808/ to browse the documentation off-line.

Good luck. However please bear in mind that this is a Ruby mailing list,
not a Rails mailing list. Rails, ActionFoo and ActiveBar questions would
best be directed elsewhere.

Chad P. wrote:

On Fri, Sep 26, 2008 at 06:23:07PM +0900, Brian C. wrote:

Rails locates a template, or how to factor code out into helper methods)
rather than Erb itself.

Me? No, I’m not talking about anything directly Rails-related. I, for
instance, use an erb implementation all the time, and basically never
use
Rails.

As far as I understand it, raw ERB is just

ERB.new(File.read("/path/to/template")).result(binding)

You said:

“Greater visibility of certain documentation matters might be nice, too,
like all the default path and custom path definition stuff that goes on
when working with an erb implementation.”

But that didn’t make much sense to me, except in the context of some
particular framework which uses ERB, where the framework will do things
like locating a template for a particular controller/action.

Can you give an example of what you mean?

On Fri, Sep 26, 2008 at 06:23:07PM +0900, Brian C. wrote:

Rails locates a template, or how to factor code out into helper methods)
rather than Erb itself.

Me? No, I’m not talking about anything directly Rails-related. I, for
instance, use an erb implementation all the time, and basically never
use
Rails.

I found the book “Agile Web D. with Rails” to be extremely
good. Don’t buy the 2nd edition - the 3rd edition for Rails 2.x is under
development. However you can buy the 3rd edition beta PDF now, and get
free updates until the final release.

I have the first edition, actually. I don’t really use Rails, though.

On Mon, Sep 29, 2008 at 04:59:01PM +0900, Brian C. wrote:

As far as I understand it, raw ERB is just
particular framework which uses ERB, where the framework will do things
like locating a template for a particular controller/action.

Can you give an example of what you mean?

in a file:

index.rhtml


test file


<%
puts "

    "
    Dir.entries.each do |file|
    puts "
  1. #{file}
  2. "
    end
    puts "
"
%>

“default path”

What directory’s contents get listed with the above code?

The answer is relatively easy to find out – but more visible
documentation of stuff like that might help eliminate a lot of flailing
about, trying stuff in code just to see if it works as expected by a
first guess, then deleting it and trying something different.

Am Donnerstag, den 25.09.2008, 02:25 +0900 schrieb Kenneth McDonald:

I have “Ruby for Rails” coming in in a few days, but in the meantime,
is there a good online ref for erb? I haven’t been able to find one.
Just to mention http://www.gotapi.com/rubyrails

g jo