ERb Handling

Embedded Ruby (ERb) is a technique for embedding Ruby code into other types of documents. The combination is then processed, executing the embedded code and generating (typically) a Ruby-free document.

ERb is typically used in Ruby on Rails apps to generate HTML and YAML files, but it can be used to good effect with other text-based file formats, including CSS, CSV, and JavaScript.

Here is a usage example:

<%# Foo/main.html.erb - view for Foo main window #%>

<%= render(:partial => 'head',
           :locals  => { :title => 'Foo' } ) %>

  <body>
    <h1>Foo</h1>
    <%= @ht.get(:main) %>
...

The Plugin Framework's implementation of this technique can be found in _Framework/Common/Code/lib/Ruby/pf_erb_view.rb (eg, erb_files, render).


This wiki page is maintained by Rich Morin, an independent consultant specializing in software design, development, and documentation. Please feel free to email comments, inquiries, suggestions, etc!

Topic revision: r5 - 02 Jan 2012, RichMorin
This site is powered by Foswiki Copyright © by the contributing authors. All material on this wiki is the property of the contributing authors.
Foswiki version v2.1.6, Release Foswiki-2.1.6, Plugin API version 2.4
Ideas, requests, problems regarding CFCL Wiki? Send us email