Sha256: 9c8a17e923338105b150f117f78f271b5ad994dceb5e09370b2a4918fd0d9a84

Contents?: true

Size: 568 Bytes

Versions: 2

Compression:

Stored size: 568 Bytes

Contents

module QEDProject
  module Helpers
    # Reads a template from the file system,
    # evaluates it with ERB
    # places it in the output folder specified.
    # Takes the binding context as the last parameter
    # so that ERb has access to instance variables, etc.
    # This works similar to how Rails and Sinatra templates
    # work.
    def render_template_to_file(template, file, context)
      t = File.read(File.join(self.template_root, template))
      File.open(file, "w") do |f|
        f << ERB.new(t, nil, "-").result(context)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
qedproject-0.0.5 lib/qedproject/helpers.rb
qedproject-0.0.4 lib/qedproject/helpers.rb