Sha256: cee492d167d760ac6ff659e0dc96b05bba00711cf04dc651897e1706b0bf4b50
Contents?: true
Size: 1.07 KB
Versions: 4
Compression:
Stored size: 1.07 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 # 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 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.13 | lib/vedeu/support/template.rb |
vedeu-0.4.12 | lib/vedeu/support/template.rb |
vedeu-0.4.11 | lib/vedeu/support/template.rb |
vedeu-0.4.10 | lib/vedeu/support/template.rb |