ยง2023-02-28

'erb' Refers to Embedded Ruby, which is a template engine in which Ruby language embeds into HTML. To make it clearer: Is the engine needed to be able to use the Ruby language with all its features inside HTML code.

Rails use erb as its default engine to render views. It uses a specific implementation called erubi.

To use erb in Rails, files should all have a .html.erb extension for Rails to process them in its asset-pipeline.

An ERB template is a file that ends with an .html.erb or .erb extension.

require 'erb'

input = <<-HEREDOC
<ul>
<% (0..5).each do |i| %>
    <%# This is a comment %>
    <li><%= i %> is <%= i.even? ? 'even' : 'odd' %>.</li>
<% end %>
</ul>
HEREDOC

parser = ERB.new(input)
output = parser.result
print output