Erbse

An updated version of Erubis.

Erbse compiles an ERB string to a string of Ruby. It is completely decoupled from any framework and does only one thing. Pretty boring, I know.

Added features

  • Block support a la Rails.
  <%= form_tag .. do |f| %>
    <%= f.fields_for do %>
     ...
    <% end %>
  <% end %>

API

The API is extremely simple.

Erbse::Template.new("<% ... %>").call #=> string of compiled ruby.

Template only accepts a content string which is the ERB template. The only public #call method returns a string of the compiled template that can then be evaluated in a context.

The user layer, like Tilt, has to take care of caching the Erbse::Template instances.

Planned

Block inheritance.

<h1><%= title %></h1>

<% fragment :subheader do %>
  Or: <%= subheader %>
<% end %>

This fragment could then be overridden.

Feel free to contribute!!!

Used where?

Erbse is the ERB engine in Cells 4.

It also hopefully gets used in Rails 5/6, so we can remove those horrible hacks from AV.

License

MIT License

Contributors

  • @iazel
  • @seuros

Authors