Sha256: bac98754ed5477671daac5659c5e69374bc839f97575f01620b135f3b209a089
Contents?: true
Size: 1.08 KB
Versions: 4
Compression:
Stored size: 1.08 KB
Contents
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 # Returns a new instance of Vedeu::Template. # # @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 protected # @!attribute [r] object # @return [Class] attr_reader :object private # @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? unless File.exist?(@path) fail MissingRequired, 'Template file cannot be found.' end @path end end # Template end # Vedeu
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
vedeu-0.4.22 | lib/vedeu/support/template.rb |
vedeu-0.4.21 | lib/vedeu/support/template.rb |
vedeu-0.4.20 | lib/vedeu/support/template.rb |
vedeu-0.4.19 | lib/vedeu/support/template.rb |