Sha256: ec8da8023bc5dd6c536e5c58dff61a75526cb77b8056b1f0790404fb49a3bd56

Contents?: true

Size: 526 Bytes

Versions: 6

Compression:

Stored size: 526 Bytes

Contents

#
# ERB Base class
#
class SmallCage::ErbBase
  def initialize(loader, renderer, obj)
    @loader, @renderer, @obj = loader, renderer, obj
  end

  def method_missing(*args)
    if 1 < args.length
      msg = 'method_missing called with more than one argument: ' +
        "#{ @renderer.current_template } #{ args.inspect }"
      fail NameError, msg
    end

    name = args[0].to_s
    return @obj[name] unless @obj[name].nil?

    # render if template file exists. or return nil.
    @renderer.render(name, @obj)
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
smallcage-0.3.2 lib/smallcage/erb_base.rb
smallcage-0.3.1 lib/smallcage/erb_base.rb
smallcage-0.3.0 lib/smallcage/erb_base.rb
smallcage-0.2.9 lib/smallcage/erb_base.rb
smallcage-0.2.8 lib/smallcage/erb_base.rb
smallcage-0.2.7 lib/smallcage/erb_base.rb