modruby.net

the Apache/Ruby integration project

Download

HTTP

Subversion

ViewCVS

at 2004-09-27 14:18 / permalink

Syntax of eRuby

A Ruby block starts with `<%' and ends with `%>'. eRuby replaces the block with its output.

  $ cat foo
  Hello, <% print "World!" %>
  $ eruby foo
  Hello, World!

If `<%' is followed by `=', eRuby replaces the block with a value of the block.

  $ cat bar
  Hello, <%= "World!" %>
  $ eruby bar
  Hello, World!

If `<%' is followed by `#', the block is ignored as a comment.

  $ cat baz
  Hello,<%# this is
  a comment %> World!
  $ eruby baz
  Hello, World!

If a line starts with '%', eRuby evaluates the line as a Ruby program and replaces the line with its output.

  $ cat quux
  % x = 1 + 1
  1 + 1 = <%= x %>
  $ eruby quux
  1 + 1 = 2
at 2004-07-07 16:45 / permalink

What's eruby?

eruby is an implementation of eRuby by C.

eRuby is a language to embed Ruby codes into text files. For example, you can embed Ruby codes into HTML files.

at 2004-07-07 15:55 / permalink

Sponsored by NaCl
Generated by lily 0.1.5
Powered by ruby 1.8.5 / mod_ruby 1.2.6