Sha256: 0c4634bf9d3849401cc18d162dbb15ea27a490ba1283f60467974f9c123c1b59

Contents?: true

Size: 473 Bytes

Versions: 212

Compression:

Stored size: 473 Bytes

Contents

require 'erubis'
s = "hello <%= name %>"
eruby = Erubis::Eruby.new(s)
filename = 'hello.rhtml'

## define instance method to Dummy class (or module)
class Dummy; end
eruby.def_method(Dummy, 'render(name)', filename)  # filename is optional
p Dummy.new.render('world')    #=> "hello world"

## define singleton method to dummy object
obj = Object.new
eruby.def_method(obj, 'render(name)', filename)    # filename is optional
p obj.render('world')          #=> "hello world"

Version data entries

212 entries across 186 versions & 44 rubygems

Version Path
rango-0.1.pre vendor/erubis/test/data/users-guide/def_method.rb
simple-templater-0.0.1 vendor/erubis/test/data/users-guide/def_method.rb
merb-core-1.1.0.pre spec10/public/webrat/test_app/gems/gems/erubis-2.6.2/test/data/users-guide/def_method.rb
erubis-2.6.5 test/data/users-guide/def_method.rb
erubis-2.4.1 test/data/users-guide/def_method.rb
erubis-2.6.2 test/data/users-guide/def_method.rb
erubis-2.4.0 test/data/users-guide/def_method.rb
erubis-2.6.0 test/data/users-guide/def_method.rb
erubis-2.6.3 test/data/users-guide/def_method.rb
erubis-2.6.1 test/data/users-guide/def_method.rb
erubis-2.5.0 test/data/users-guide/def_method.rb
erubis-2.6.4 test/data/users-guide/def_method.rb