[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

erb reference anywhere online?

Kenneth McDonald

9/24/2008 5:26:00 PM

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

4 Answers

Brian Candler

9/24/2008 8:14:00 PM

0

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

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

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 %>
--
Posted via http://www.ruby-....

Brian Candler

9/26/2008 9:23:00 AM

0

> 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.rubyon...
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.
--
Posted via http://www.ruby-....

Brian Candler

9/29/2008 7:59:00 AM

0

Chad Perrin wrote:
> On Fri, Sep 26, 2008 at 06:23:07PM +0900, Brian Candler 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?
--
Posted via http://www.ruby-....

Johannes J. Schmidt

10/6/2008 7:55:00 PM

0

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

g jo