eRuby
eRuby stands for embedded Ruby; it’s a tool that embeds fragments of Ruby code in other files such as HTML files. Here’s a sample eRuby file:
This is sample eRuby file<br> The current time here is <%=Time.now%>. <%[1,2,3].each{|x|print x,"<br>\n"}%>
Here’s the output from this sample file:
This is sample eRuby file<br> The current time here is Wed Aug 29 18:54:45 JST 2001. 1 2 3
There are two eRuby implementations:
- eruby
The original implementation of eRuby. eruby is available from http://www.modruby.net.
- Erb
A pure Ruby (subset) implementation of eRuby.
eRuby is available from http://www2a.biglobe.ne.jp/~seki/ruby/erb-1.3.3.tar.gz; The version number may be changed in the future. Unfortunately, the supporting page http://www2a.biglobe.ne.jp/~seki/ruby/ is in Japanese, but you can tell how to use it from its source code.
Get Ruby in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.