class DockDriver::Template
This class provides a binding/namespace for ERB templating.
Public Class Methods
render( tmpl, items )
click to toggle source
A factory method to render the template, given a string, and a list of objects that respond to :to_s
.
Returns the result of the template.
Example:
my_tmpl = "<%= date %>" DockDriver::Template.render( my_tmpl, [] ) => '2012-10-05 11:30:22'
# File lib/dock_driver/template.rb, line 20 def self::render( tmpl, items ) tmpl = ERB.new( tmpl ) result = tmpl.result( self.new( items ).instance_eval { binding } ) return result.gsub( /\s+/, ' ' ) end
Public Instance Methods
method_missing( sym, *args, &block )
click to toggle source
Handle missing methods gracefully, by returning a red ! instead.
# File lib/dock_driver/template.rb, line 27 def method_missing( sym, *args, &block ) return '^fg(red)!^fg()' end
pager()
click to toggle source
Get the workspace pager as a string. See WorkspacePager
. Example:
<%= pager %>
# File lib/dock_driver/template.rb, line 40 def pager return DockDriver::pager.to_s end