ERUBIS(1)

🌸 NAME 🌸

erubis β€” the eRuby style template engine for multiple languages πŸ’–

Yep, you're reading the erubis(1) manual page, and honestly? It's giving iconic. Sit down, grab a boba, we're doing this together πŸ§‹βœ¨


✨ SYNOPSIS ✨

erubis [..options..] [file ...]

πŸ’– DESCRIPTION πŸ’–

So here's the vibe: erubis is an embedded templating engine that speaks multiple languages. Not like, metaphorically. For real.

You hand it a template file as input, and it hands you back code that conveys that data in whatever language you asked for. That's it, that's the whole job, and it does it flawlessly πŸ‘‘

The output languages it supports:

  • Ruby
  • PHP
  • C
  • Java
  • Scheme
  • Perl
  • JavaScript

πŸŽ€ OPTIONS πŸŽ€

  • -h, --help β€” help, bestie. It gives you help.
  • -v β€” version
  • -x β€” show converted code
  • -X β€” show converted code, only ruby code and no text part
  • -N β€” numbering: add line numbers (for -x/-X)
  • -U β€” unique: compress empty lines to a line (for -x/-X)
  • -C β€” compact: remove empty lines (for -x/-X)
  • -b β€” body only: no preamble nor postamble (for -x/-X)
  • -z β€” syntax checking
  • -e β€” escape (equal to --E Escape)
  • -p pattern β€” embedded pattern (default <% %>)
  • -l lang β€” convert but no execute (ruby/php/c/java/scheme/perl/js)
  • -E e1,e2,... β€” enhancer names (Escape, PercentLine, BiPattern, ...)
  • -I path β€” library include path
  • -K kanji β€” kanji code (euc/sjis/utf8) (default none)
  • -c context β€” context data string (yaml inline style or ruby code)
  • -f datafile β€” context data file (*.yaml, *.yml, or *.rb)
  • -T β€” don't expand tab characters in YAML file
  • -S β€” convert mapping key from string to symbol in YAML file
  • -B β€” invoke result(binding) instead of evaluate(context)
  • --pi=name β€” parse <?name ... ?> instead of <% ... %>

πŸ¦‹ supported properties πŸ¦‹

🌟 (common)

  • --escapefunc=nil β€” : escape function name
  • --pattern="<% %>" β€” : embed pattern
  • --trim=true β€” : trim spaces around <% ... %>
  • --preamble=nil β€” : preamble (no preamble when false)
  • --postamble=nil β€” : postamble (no postamble when false)
  • --escape=nil β€” : escape expression or not in default

πŸ’« (basic) ✦ (pi)

  • --pi="rb" β€” : PI (Processing Instrunctions) name
  • --embchar="@" β€” : char for embedded expression pattern('@{...}@')

🌈 (ruby) ✦ (php) ✦ (c)

  • --indent="" β€” : indent spaces (ex. ' ')
  • --out="stdout" β€” : output file pointer name

πŸ‘‘ (java)

  • --indent="" β€” : indent spaces (ex. ' ')
  • --buf="_buf" β€” : output buffer name
  • --bufclass="StringBuffer" β€” : output buffer class (ex. 'StringBuilder')

πŸ“ (scheme)

  • --func="_add" β€” : function name (ex. 'display')

🧚 (perl)

  • --func="print" β€” : function name

⭐ (javascript)

  • --docwrite=true β€” : use 'document.write()' when true

πŸ”₯ EXAMPLES πŸ”₯

Okay so this is the part where it gets fun. Run this:

erubis -l php example.ephp

and boom β€” it converts the embedded document to php code. Obsessed, honestly.

Here's what example.ephp looks like:

<?xml version="1.0"?>
<html>
 <body>
  <p>Hello <%= $user %>!</p>
  <table>
   <tbody>
    <% $i = 0; %>
    <% foreach ($list as $item) { %>
    <%   $i++; %>
    <tr bgcolor="<%= $i % 2 == 0 ? '#FFCCCC' : '#CCCCFF' %>">
     <td><%= $i %></td>
     <td><%== $item %></td>
    </tr>
    <% } %>
   </tbody>
  </table>
 </body>
</html>

πŸ’œ SEE ALSO πŸ’œ

http://rubyforge.org/projects/erubis/


erubis 2.6.2 · January 2009 🫢

That's the whole page, bestie. Version 2.6.2, dated January 2009, and it still ate πŸ’…βœ¨ no cap, go template something gorgeous 🌸

πŸ“¦ where this page comes from