‹The template How-to is being considered for merging.›
This article contains instructions, advice, or how-to content. (October 2016) |
This article may require cleanup to meet Wikipedia's quality standards. The specific problem is: Inconsistent wikilinks, capitalization, and general unclear writing throughout. (August 2022) |
Other names | ERB |
---|---|
Repository | github |
Written in | Ruby |
Type | Template engine |
License | BSD 2-Clause License |
Embedded Ruby (also shortened as ERB) 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 and JSP, and PHP and other server-side scripting languages. The templating system of eRuby combines Ruby code and plain text to provide flow control and variable substitution, thus making the combined code easier to maintain.[1]
The View module of Ruby on Rails is responsible for displaying the response or output on a browser. In its simplest form, a view can be a piece of HTML code which has some static content. For most applications, just having static content may not be enough. Many Ruby on Rails applications will require dynamic content created by the controller (action method) to be displayed in their view. This is made possible by using Embedded Ruby to generate templates which can contain dynamic content. Embedded Ruby allows ruby code to be embedded in a view document. This code gets replaced with proper value resulted from the execution of the code at run time. But, by having the ability to embed code in a view document, we risk bridging the clear separation present in the MVC frame. It is thus the responsibility of the developer to make sure that there is a clear separation of responsibility among the model, view and controller modules of his/her application.[2]
:2
was invoked but never defined (see the help page).