class Superb::Template

Templates are bound to a specific ERB instance. They maintain their own state, but they also allow for individual values to be overridden when being rendered.

Attributes

__erb[RW]

Public Class Methods

new(erb, options = {}) click to toggle source
# File lib/superb.rb, line 98
def initialize(erb, options = {})
  @__erb = erb
  self.merge!(options)
end
open(path, options = {}) click to toggle source
# File lib/superb.rb, line 103
def self.open(path, options = {})
  erb = Kernel.open(path){|fin| ERB.new(fin.read) }
  self.new(erb, options)
end

Public Instance Methods

dup() click to toggle source
# File lib/superb.rb, line 108
def dup
  Superb::Template.new(@__erb, self.to_hash)
end
render(options = {}) click to toggle source
# File lib/superb.rb, line 112
def render(options = {})
  c = Superb::Context.new(self.to_hash)
  c.merge!(options)
  c.apply_to(@__erb)
end