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
vagrant-unbundled-2.2.10.0 vendor/bundle/ruby/2.7.0/gems/erubis-2.7.0/test/data/users-guide/def_method.rb
vagrant-unbundled-2.2.9.0 vendor/bundle/ruby/2.7.0/gems/erubis-2.7.0/test/data/users-guide/def_method.rb
files.com-1.0.55 docs/vendor/bundle/ruby/2.5.0/gems/erubis-2.7.0/test/data/users-guide/def_method.rb
vagrant-unbundled-2.2.8.0 vendor/bundle/ruby/2.7.0/gems/erubis-2.7.0/test/data/users-guide/def_method.rb
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.6.0/gems/erubis-2.7.0/test/data/users-guide/def_method.rb
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.7.0/gems/erubis-2.7.0/test/data/users-guide/def_method.rb
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.4.0/gems/erubis-2.7.0/test/data/users-guide/def_method.rb
vagrant-unbundled-2.2.6.2 vendor/bundle/ruby/2.6.0/gems/erubis-2.7.0/test/data/users-guide/def_method.rb
vagrant-unbundled-2.2.6.1 vendor/bundle/ruby/2.6.0/gems/erubis-2.7.0/test/data/users-guide/def_method.rb
vagrant-unbundled-2.2.6.0 vendor/bundle/ruby/2.6.0/gems/erubis-2.7.0/test/data/users-guide/def_method.rb
vagrant-unbundled-2.2.5.0 vendor/bundle/ruby/2.5.0/gems/erubis-2.7.0/test/data/users-guide/def_method.rb
vagrant-unbundled-2.2.5.0 vendor/bundle/ruby/2.6.0/gems/erubis-2.7.0/test/data/users-guide/def_method.rb
vagrant-unbundled-2.2.4.0 vendor/bundle/ruby/2.5.0/gems/erubis-2.7.0/test/data/users-guide/def_method.rb
vagrant-unbundled-2.2.4.0 vendor/bundle/ruby/2.6.0/gems/erubis-2.7.0/test/data/users-guide/def_method.rb
vagrant-unbundled-2.2.3.0 vendor/bundle/ruby/2.5.0/gems/erubis-2.7.0/test/data/users-guide/def_method.rb
vagrant-unbundled-2.2.2.0 vendor/bundle/ruby/2.5.0/gems/erubis-2.7.0/test/data/users-guide/def_method.rb
vagrant-unbundled-2.2.0.0 vendor/bundle/ruby/2.5.0/gems/erubis-2.7.0/test/data/users-guide/def_method.rb
vagrant-unbundled-2.1.4.0 vendor/bundle/ruby/2.5.0/gems/erubis-2.7.0/test/data/users-guide/def_method.rb
vagrant-unbundled-2.1.2.0 vendor/bundle/ruby/2.3.0/gems/erubis-2.7.0/test/data/users-guide/def_method.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/erubis-2.7.0/test/data/users-guide/def_method.rb