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)-ppattern β embedded pattern (default<% %>)-llang β convert but no execute (ruby/php/c/java/scheme/perl/js)-Ee1,e2,... β enhancer names (Escape,PercentLine,BiPattern, ...)-Ipath β library include path-Kkanji β kanji code (euc/sjis/utf8) (default none)-ccontext β context data string (yaml inline style or ruby code)-fdatafile β 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β invokeresult(binding)instead ofevaluate(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
- debian bookworm: ruby-erubis 2.7.0-3.1 Β· MIT
- debian trixie: ruby-erubis 2.7.0-4 Β· MIT
- ubuntu jammy: ruby-erubis 2.7.0-3.1 Β· MIT
- ubuntu noble: ruby-erubis 2.7.0-3.1 Β· MIT
- ubuntu resolute: ruby-erubis 2.7.0-4 Β· MIT
- ubuntu stonking: ruby-erubis 2.7.0-4 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms