Ruby eruby

From wikinotes

A templating engine builtin to ruby. Commonly used within ruby rails .

File extension is .erb.

Documentation

homepage https://docs.ruby-lang.org/en/2.7.0/ERB.html

Usage

require "erb"

# locals will be passed to ERB template
name = "You"

# create template, and render it using locals
template = ERB.new("hello <%= name %>")
template.resuilt(binding)

Syntax

Tags

<!-- comment -->
<%# comment %>

<!-- NOTE: no comments can escape eruby end '%>' -->
<!-- variable value -->
<%= value %>
<!-- statements -->
<% 5.times do %>
  <p>hello.</p>
<% end %>