# man > erubis(1)

---
type: CommandReference
command: erubis
mode: man
section: 1
source: man-pages
---

## Quick Reference

- `erubis -l php example.ephp` — convert embedded PHP template to PHP code
- `erubis -l ruby example.eruby` — convert embedded Ruby template to Ruby code
- `erubis -l c example.ec` — convert embedded C template to C code
- `erubis -l java example.ejava` — convert embedded Java template to Java code
- `erubis -l js example.ejs` — convert embedded JavaScript template to JavaScript code
- `erubis -p '<% %>' file` — set custom embed pattern
- `erubis -E Escape file` — enable Escape enhancer
- `erubis -c "yaml_data" file` — supply context data as YAML inline

## Name

erubis — eRuby style template engine for multiple languages

## Synopsis

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

## Options

### Common options
- `-h, --help` — show help
- `-v` — verbose
- `-x` — (description not provided)
- `-X` — (description not provided)
- `-N` — (description not provided)
- `-U` — (description not provided)
- `-C` — (description not provided)
- `-b` — (description not provided)
- `-z` — (description not provided)
- `-e` — (description not provided)
- `-p, --pattern` — embedded pattern (default `<% %>`)
- `-l, --lang` — output language: `ruby`, `php`, `c`, `java`, `scheme`, `perl`, `js` (convert but no execute)
- `-E, --enhancer` — enhancer names (e.g. `Escape`, `PercentLine`, `BiPattern`)
- `-I, --include` — library include path
- `-K, --kanji` — kanji code: `euc`, `sjis`, `utf8` (default none)
- `-c, --context` — context data string (YAML inline style or Ruby code)
- `-f, --file` — context data file (`*.yaml`, `*.yml`, or `*.rb`)
- `-T` — (description not provided)
- `-S` — (description not provided)
- `-B` — (description not provided)
- `--pi` — parse `<?name ... ?>` instead of `<% ... %>`

### Additional properties (per language)

#### Common
- `--escapefunc` — escape function name (default `nil`)
- `--pattern` — embed pattern (default `<% %>`)
- `--trim` — trim spaces around `<% ... %>` (default `true`)
- `--preamble` — preamble code (no preamble when `false`)
- `--postamble` — postamble code (no postamble when `false`)
- `--escape` — escape expression or not in default

#### Basic and PI
- `--pi` — PI (Processing Instruction) name (default `rb`)
- `--embchar` — char for embedded expression pattern (default `@`)

#### Ruby, PHP, C
- `--indent` — indent spaces (e.g. `'  '`)
- `--out` — output file pointer name (default `stdout`)

#### Java
- `--indent` — indent spaces (e.g. `'  '`)
- `--buf` — output buffer name (default `_buf`)
- `--bufclass` — output buffer class (e.g. `StringBuffer`, `StringBuilder`)

#### Scheme
- `--func` — function name (default `_add`)

#### Perl
- `--func` — function name (default `print`)

#### JavaScript
- `--docwrite` — use `document.write()` when true

## Examples

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

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

- [Erubis project on RubyForge](http://rubyforge.org/projects/erubis/)