Top 1,000 Features Creators Events Podcasts Extensions Interviews Blog Explorer CSV


< >

ERB is a template language created in 2004.

#560on PLDB 20Years Old 276Repos

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.The View module of the rails is responsible to display the response or output on a browser. Read more on Wikipedia...

Example from the web:
<ul> <% 4.times do %> <li>list item</li> <% end %> </ul>
Example from Linguist:
<% provide(:title, @header) %> <% present @users do |user_presenter| %> <div class="row key-header"> <h1><%= @header %></h1> </div> <div class='row'> <div class='small-12 columns'> <%= will_paginate %> </div> </div> <div class="row key-table"> <div class="small-12 columns"> <div class="row key-table-row"> <div class="small-2 columns">Name</div> <div class="small-3 columns">Email</div> <div class="small-1 columns">Chords</div> <div class="small-1 columns">Keys</div> <div class="small-1 columns">Tunings</div> <div class="small-1 columns">Credits</div> <div class="small-1 columns">Prem?</div> <div class="small-2 columns">Since?</div> </div> <% if @users == [] %> <div class="row key-table-row"> <div class="small-4 small-centered columns">No Users</div> </div> <% else %> <%= render @users %> <% end %> </div> </div> <div class='row'> <div class='small-12 columns'> <%= will_paginate %> </div> </div> <% end %>
Example from Wikipedia:
class ERBExample attr_accessor:variable1 # using bind to access class variables def render() renderer.result(binding) end def initialize(variable1) @variable1 = variable1 end # Expose private binding() method. def get_binding binding() end end example = renderer = puts output = renderer.result(example.get_binding)

View source

- Build the next great programming language About Resources Acknowledgements Part of the World Wide Scroll