Sha256: 87e9d704f75bb560f89209f43f54186334b806221918abf4bcf081d07a679094

Contents?: true

Size: 303 Bytes

Versions: 2

Compression:

Stored size: 303 Bytes

Contents

require 'erb'
require 'ostruct'

module Linecook
  class Template
    attr_reader :erb
    
    def initialize(filename)
      @erb = ERB.new File.read(filename)
      @erb.filename = filename
    end
    
    def build(locals={})
      erb.result OpenStruct.new(locals).send(:binding)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
linecook-1.1.0 lib/linecook/template.rb
linecook-1.0.0 lib/linecook/template.rb