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