Quantcast
Channel: Dave Copeland :ruby:
Viewing all articles
Browse latest Browse all 586

Article 3

$
0
0

The lengths Rails goes to to enable this:

```erb
<%= form_for(Widget) do %>
<h1>Inside form</h1>
<% end %>
```

is amazing. It has to subclass Erubi::Engine and override most methods.

Erubi/ERB treat <%= xxx %> as an expression and wrap it in parens `_buf << (xxx)`

Thus, `_buf << (form_for(Widget) do)` is a syntax error by default.

Making something like this work in Erubi on its own is not very easy and so this is a great example of how much work Rails does to provide an ergonomic API.


Viewing all articles
Browse latest Browse all 586