Languages Features Creators CSV Resources Challenges Add Language
GitHub icon

ERB

ERB - Template language

< >

ERB is a template language created in 2004.

#316on PLDB 19Years Old 400Users
0Books 0Papers 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 = ERBExample.new(variable1) renderer = ERB.new(template) puts output = renderer.result(example.get_binding)
general-algebraic-modeling-system.html 路 erb.html 路 autohotkey.html

View source

- Build the next great programming language Search Day 213 About Blog Acknowledgements Traffic Traffic Today GitHub feedback@pldb.com