Sha256: eaadae93fca60c1583eee9dc69704be87970cb9c3715de3c43643238e15f0e70
Contents?: true
Size: 1.02 KB
Versions: 4
Compression:
Stored size: 1.02 KB
Contents
require 'erb' module Vedeu # Generic class to loading a template and parsing it via ERb. # class Template # @param object [Class] # @param path [String] # @return [void] def self.parse(object, path) new(object, path).parse end # @param object [Class] # @param path [String] # @return [Template] def initialize(object, path) @object, @path = object, path.to_s end # @return [void] def parse ERB.new(load, nil, '-').result(binding) end private # @!attribute [r] object # @return [Class] attr_reader :object # @return [String] def load File.read(path) end # @raise [MissingRequired] when the path is empty. # @raise [MissingRequired] when the path does not exist. # @return [String] def path fail MissingRequired, 'No path to template specified.' if @path.empty? fail MissingRequired, 'Template file cannot be found.' unless File.exist?(@path) @path end end # Template end # Vedeu
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
vedeu-0.4.9 | lib/vedeu/support/template.rb |
vedeu-0.4.8 | lib/vedeu/support/template.rb |
vedeu-0.4.7 | lib/vedeu/support/template.rb |
vedeu-0.4.6 | lib/vedeu/support/template.rb |