erb reference anywhere online?

K

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.

Thanks,
Ken
 
B

Brian Candler

Kenneth said:
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 %>
 
B

Brian Candler

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 Development 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.
 
B

Brian Candler

Chad said:
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?
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,200
Messages
2,571,046
Members
47,646
Latest member
xayaci5906

Latest Threads

Top