ERB (Class)

In: libraries/erb.rb
Parent: Object

Methods

def_class   def_method   def_module   new   result   run   set_eoutvar   version  

Constants

Revision = '$Date: 2004/02/23 23:40:09 $'

Attributes

src  [R] 

Public Class methods

[Source]

     # File libraries/erb.rb, line 404
404:   def initialize(str, safe_level=nil, trim_mode=nil, eoutvar='_erbout')
405:     @safe_level = safe_level
406:     compiler = ERB::Compiler.new(trim_mode)
407:     set_eoutvar(compiler, eoutvar)
408:     @src = compiler.compile(str)
409:   end

[Source]

    # File libraries/erb.rb, line 8
 8:   def self.version
 9:     "erb.rb [2.0.4 #{ERB::Revision.split[1]}]"
10:   end

Public Instance methods

[Source]

     # File libraries/erb.rb, line 452
452:   def def_class(superklass=Object, methodname='result')
453:     cls = Class.new(superklass)
454:     def_method(cls, methodname)
455:     cls
456:   end

[Source]

     # File libraries/erb.rb, line 442
442:   def def_method(mod, methodname, fname='(ERB)')
443:     mod.module_eval("def #{methodname}\n" + self.src + "\nend\n", fname, 0)
444:   end

[Source]

     # File libraries/erb.rb, line 446
446:   def def_module(methodname='erb')
447:     mod = Module.new
448:     def_method(mod, methodname)
449:     mod
450:   end

[Source]

     # File libraries/erb.rb, line 430
430:   def result(b=TOPLEVEL_BINDING)
431:     if @safe_level
432:       th = Thread.start { 
433:         $SAFE = @safe_level
434:         eval(@src, b)
435:       }
436:       return th.value
437:     else
438:       return eval(@src, b)
439:     end
440:   end

[Source]

     # File libraries/erb.rb, line 426
426:   def run(b=TOPLEVEL_BINDING)
427:     print self.result(b)
428:   end

[Source]

     # File libraries/erb.rb, line 412
412:   def set_eoutvar(compiler, eoutvar = '_erbout')
413:     compiler.put_cmd = "#{eoutvar}.concat"
414: 
415:     cmd = []
416:     cmd.push "#{eoutvar} = ''"
417:     
418:     compiler.pre_cmd = cmd
419: 
420:     cmd = []
421:     cmd.push(eoutvar)
422: 
423:     compiler.post_cmd = cmd
424:   end

[Validate]