
- Ruby on Rails Tutorial
- Ruby on Rails - Home
- Ruby on Rails - Introduction
- Ruby on Rails - Installation
- Ruby on Rails - Framework
- Ruby on Rails - Directory Structure
- Ruby on Rails - Examples
- Ruby on Rails - Database Setup
- Ruby on Rails - Active Records
- Ruby on Rails - Migrations
- Ruby on Rails - Controllers
- Ruby on Rails - Routes
- Ruby on Rails - Views
- Ruby on Rails - Layouts
- Ruby on Rails - Scaffolding
- Ruby on Rails - AJAX
- Ruby on Rails - File Uploading
- Ruby on Rails - Send Emails
- Ruby on Rails Resources
- Ruby on Rails - References Guide
- Ruby on Rails - Quick Guide
- Ruby on Rails - Resources
- Ruby on Rails - Discussion
- Ruby Tutorial
- Ruby Tutorial
Ruby on Rails - HTML.ERB
HTML.ERB is HTML mixed with Ruby, using HTML tags. All of Ruby is available for programming along with HTML.
Following is the syntax of using Ruby with HTML −
<% %> # executes the Ruby code <%= %> # executes the Ruby code and displays the result
Example
<ul> <% @products.each do |p| %> <li><%= @p.name %></li> <% end %> </ul>
The output of anything in <%= %> tags is directly copied to the HTML output stream. To secure against HTML injection, use the h() function to html_escape the output
For example
<%=h @user_entered_notes %>
Please check the following link on XML Builder.
rails-references-guide.htm
Advertisements