Create  Edit  Diff  FrontPage  Index  Search  Changes  Login

eRubySyntax

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
Last modified:2004/11/16 15:54:51
Keyword(s):
References:[FrontPage]