Sha256: 448918619d4d05d56075c4ad7db1bfc25b80e930edf9fa6e3f1d488df423bd18
Contents?: true
Size: 885 Bytes
Versions: 6
Compression:
Stored size: 885 Bytes
Contents
require 'erubis' module Saga class Formatter TEMPLATE_PATH = File.expand_path('../../../templates', __FILE__) def initialize(document, options={}) @document = document @options = options @options[:template] ||= 'default' end def format template_path = File.join(self.class.template_path, @options[:template]) helpers_file = File.join(template_path, 'helpers.rb') load helpers_file @document.extend(Helpers) binding = @document.send(:binding) template_file = File.join(template_path, 'document.erb') template = Erubis::Eruby.new(File.read(template_file)) template.result(binding) end def self.format(document, options={}) formatter = new(document, options) formatter.format end def self.template_path TEMPLATE_PATH end end end
Version data entries
6 entries across 6 versions & 1 rubygems