User:Sweekrut.joshi/sandbox

Introduction
eRuby (Embedded Ruby) is a templating system that embeds Ruby into a text document. It is often used to embed Ruby code in an HTML document, similar to ASP, JSP and PHP. The templating system of eRuby combines the ruby code and the plain text to provide flow control and variable substitution. Thus making it easy to maintain.

Usage
eRuby allows Ruby code to be embedded within a pair of  and   delimiters. These embedded code blocks are then evaluated in-place (they are replaced by the result of their evaluation). Apart from creating web pages, eRuby can also be used to create XML Documents, RSS feeds and other forms of structured text files. eRuby dynamically generates static files based on templates. These functionalities of eRuby can be found in the ERB Library. Different types of tag markers used in ERB templates are:
 * 1) Expression Tags
 * 2) Execution Tags
 * 3) Comment Tags

Expression Tags
<%= %> : This indicates that the tag encloses an expression. Such a tag starts with an opening tag delimiter followed by an equal to symbol and ends with an end tag delimiter. During the rendering of the template, this piece of code gets substituted with the result of the code. If the evaluated result is not a string, it gets converted to a string before it is rendered. For example: The resulting text looks like this: The value of x is: 50

Execution Tags
<% %> : Code enclosed in such tags is called as scriplet. The code in such a tag gets executed and its result gets replaced in place of the scriplet. Such tags must have a matching <% end %> tag to denote the end of a functional block. For example: In the above example, the text list item gets printed three times. The scriplet produces no text on it's own, it only makes the enclosed statement to run multiple times. The output of above code:
 * list item
 * list item
 * list item

Comments Tags
<%# %> : Contents of comment tags don't get rendered in the output. Such tags start with an open tag delimiter followed by a hash symbol and end with an end tag delimiter. Example of a comment tag is shown below: <%# ruby code %> This is the same as a comment in Ruby. All Ruby code after the # is ignored and generates nothing.

Implementations
There are several embedded ruby implementations available and one can choose the one best suited for him/her. Some of the important implementations are: The below table compares the tags available in each of the above implementations
 * 1) erb - erb is an implementation of eRuby written purely in the Ruby programming language and included in the Ruby standard library.
 * 2) erubis - erubis is an implementation of eRuby implemented in Ruby and also in Java. According to its home page, it runs faster than erbb and has several useful options.
 * 3) ember - It is a Linux implementation of eRuby implemented in pure ruby.