Sha256: 838985e7e283b0ce51d485dab4a835278f96df69812d95be02899f3281e5296a

Contents?: true

Size: 499 Bytes

Versions: 1

Compression:

Stored size: 499 Bytes

Contents

require 'erb'

module Twiddler
  class Rendering
    def initialize(config)
      @config = config
    end

    def embed(name)
      path = template_path(name)
      template = File::read(path)
      erb = ERB.new(template, nil, "%>")
      erb.filename = path
      mod = erb.def_module("render")
      @config.extend(mod)
    end

    def template_path(name)
      path = File::expand_path("../../templates/#{name}.erb", 
                               File::dirname(__FILE__))
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
twiddler-utils-0.0.3 lib/twiddler/rendering.rb