Scroll to navigation

ERUBIS(1) User Commands ERUBIS(1)

NAME

erubis - eRuby style template engine for multiple languages

SYNOPSIS

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

DESCRIPTION

Embedded templating engine for multiple languages. Erubis will take a template file as input and output code to convey that data in the language specified. The following output languages are supported:


* Ruby
* PHP
* C
* Java
* Scheme
* Perl
* JavaScript

OPTIONS

help
version
show converted code
show converted code, only ruby code and no text part
numbering: add line numbers (for '-x/-X')
unique: compress empty lines to a line (for '-x/-X')
compact: remove empty lines (for '-x/-X')
body only: no preamble nor postamble (for '-x/-X')
syntax checking
escape (equal to '--E Escape')
embedded pattern (default '<% %>')
convert but no execute (ruby/php/c/java/scheme/perl/js)
enhancer names (Escape, PercentLine, BiPattern, ...)
library include path
kanji code (euc/sjis/utf8) (default none)
context data string (yaml inline style or ruby code)
context data file ('*.yaml', '*.yml', or '*.rb')
don't expand tab characters in YAML file
convert mapping key from string to symbol in YAML file
invoke 'result(binding)' instead of 'evaluate(context)'
parse '<?name ... ?>' instead of '<% ... %>'

supported properties:

* (common)
: escape function name
: embed pattern
: trim spaces around <% ... %>
: preamble (no preamble when false)
: postamble (no postamble when false)
: escape expression or not in default
* (basic) * (pi)
: PI (Processing Instrunctions) name
: char for embedded expression pattern('@{...}@')
* ruby * php * c
: indent spaces (ex. ' ')
: output file pointer name
* java
: indent spaces (ex. ' ')
: output buffer name

--bufclass="StringBuffer" : output buffer class (ex. 'StringBuilder')

* scheme
: function name (ex. 'display')
* perl
: function name
* javascript
: use 'document.write()' when true

EXAMPLES

Run 'erubis -l php example.ephp' to convert the embedded document to php code.

example.ephp:
<?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/

January 2009 erubis 2.6.2