ERB(1)

πŸŽ€ ERB(1) πŸŽ€

erb β€” Ruby Templating ✨

Manual section: Ruby Programmer's Reference Guide πŸ“–

🧾 SYNOPSIS 🧾

erb [--version] [-UPdnvx] [-E ext[:int]] [-S level] [-T mode]
    [-r library] [--] [file ...]

πŸ’– DESCRIPTION πŸ’–

okay so erb is a command line front-end for the ERB library, which is an implementation of eRuby 🫢

ERB gives you an easy-to-use but seriously powerful templating system for Ruby. You can drop actual Ruby code into any plain text document to generate document details and/or handle flow control. it's giving customizable docs, bestie πŸ¦‹

erb is a part of Ruby πŸ’œ


✨ OPTIONS ✨

  • --version β€” shows you which version of erb you're running 🧚
  • -E external[:internal], --encoding external[:internal] β€” sets the default external encoding and internal encoding. separate the two with a colon (:) 🌈

you can leave out the internal one, and then the value (Encoding.default_internal) will be nil πŸ™ˆ

  • -P β€” turns off ruby code evaluation for lines that begin with % 🚫
  • -S level β€” sets the safe level that your eRuby script runs in πŸ”’
  • -T mode β€” sets the trim mode, which defaults to 0 πŸ“ mode can be one of these:
    • 0 β€” the EOL stays put after the embedded ruby script gets evaluated.
    • 1 β€” the EOL gets removed if the line ends with %>.
    • 2 β€” the EOL gets removed if the line starts with <% and ends with %>.
    • - β€” the EOL gets removed if the line ends with -%>. also, leading whitespace gets removed if the erb directive starts with <%-. πŸ’…
  • -r library β€” loads a library πŸ“š
  • -U β€” sets the default internal encoding (Encoding.default_internal) to UTF-8 🫧
  • -d, --debug β€” turns on debug mode. $DEBUG gets set to true πŸ›
  • -h, --help β€” prints a summary of the options πŸ†˜
  • -n β€” goes with -x. prepends the line number to each line of the output πŸ”’
  • -v β€” enables verbose mode. $VERBOSE gets set to true πŸ“’
  • -x β€” converts the eRuby script into a Ruby script and prints it without line numbers πŸͺ„

🌸 EXAMPLES 🌸

here's an eRuby script, periodt:

<?xml version="1.0" ?>
<% require 'prime' -%>
<erb-example>
  <calc><%= 1+1 %></calc>
  <var><%= __FILE__ %></var>
  <library><%= Prime.each(10).to_a.join(", ") %></library>
</erb-example>

the command is:

% erb -T - example.erb

and it prints:

<?xml version="1.0" ?>
<erb-example>
  <calc>2</calc>
  <var>example.erb</var>
  <library>2, 3, 5, 7</library>
</erb-example>

πŸ”— SEE ALSO πŸ”—

ruby(1).

and check out the ri(1) docs for the ERB class too πŸ€“


πŸ› REPORTING BUGS πŸ›

  • Security vulnerabilities go by email to security@ruby-lang.org. don't post them anywhere else πŸ™…β€β™€οΈ reported problems get published after they're fixed πŸ”
  • Other bugs and feature requests can go to the Ruby Issue Tracking System (https://bugs.ruby-lang.org/). do not report security vulnerabilities through this system, because it publishes them immediately 😭

πŸ‘‘ AUTHORS πŸ‘‘

written by Masatoshi SEKI πŸ’œ


ok bestie, that's the whole tea β˜• this page came from UNIX, dated December 16, 2018, and it's ERB(1) πŸŽ€πŸ’… ily, now go template something iconic πŸ¦‹βœ¨

πŸ“¦ where this page comes from