Parent

Methods

ERB::OpenTemplate

OpenTemplate

The Erb OpenTemplate provides a quick and convenient way to create a clean rendering space with the desired responses.

TODO: This might make a good addon library. Just add require ‘erb’ to the erb_result method? Call it OpenResponse?

Public Class Methods

new(*objs_ioc) click to toggle source
    # File lib/more/facets/erb.rb, line 19
19:   def initialize(*objs_ioc)
20:     ioc = Hash===objs_ioc.last ? objs_ioc.pop : {}
21:     objs = objs_ioc
22: 
23:     mods = []
24: 
25:     objs.each do |obj|
26:       mod = Module.new
27:       obj.public_methods.each do |m|
28:         mod.module_eval do
29:           define_method(m){ |*a,&b| obj.__send__(m,*a,&b) }
30:         end
31:       end
32:       mods << mod
33:     end
34: 
35:     mod = Module.new
36:     ioc.each do |k,v|
37:       mod.module_eval do
38:         define_method(k){ v }
39:       end
40:     end
41:     mods << mod
42: 
43:     extend *mods.reverse
44:   end

Public Instance Methods

erb_result(str) click to toggle source
    # File lib/more/facets/erb.rb, line 47
47:   def erb_result(str)
48:     ERB.new(str).result(binding)
49:   end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.