Skip to content

Commit

Permalink
Rails doesn't monkey-patch ERB anymore.
Browse files Browse the repository at this point in the history
Ref: 6f66034
  • Loading branch information
jodosha committed Jul 1, 2016
1 parent 7115d5f commit 0bb4469
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions source/guides/helpers/forms.md
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ It provides a powerful Ruby API to describe HTML5 forms, to be used both with vi


## Technical notes ## Technical notes


### Zero monkey-patching

This feature has a similar syntax to other Ruby gems with the same purpose, but it has a different usage if compared with Rails or Padrino. This feature has a similar syntax to other Ruby gems with the same purpose, but it has a different usage if compared with Rails or Padrino.


Those frameworks allow a syntax like this: Those frameworks allow a syntax like this:
Expand All @@ -34,13 +32,13 @@ Those frameworks allow a syntax like this:
<% end %> <% end %>
``` ```


The code above **isn't a valid ERB template**. To make it work, Rails uses monkey-patches ERB, and Padrino supports only HAML with that syntax. The code above **isn't a valid ERB template**.

To make it work, these frameworks use custom ERB handlers and rely on third-party gems for other template engines.
One of the pillars of Hanami is _"zero monkey-patch of Ruby core and stdlib"_. We want to keep this principle for this feature too.


### Template engine independent ### Template engine independent


Avoiding monkey-patching has a big advantage: **form helpers are designed to be independent from the template engine**. That means we can use Slim, HAML, or ERB and keep the same Ruby syntax. Because we support a lot of template engines, we wanted to keep it simple: use what ERB already offers.
That means we can use Slim, HAML, or ERB and keep the same Ruby syntax.


### One output block ### One output block


Expand Down

0 comments on commit 0bb4469

Please sign in to comment.