Class: Vedeu::Templating::Template Private
- Inherits:
-
Object
- Object
- Vedeu::Templating::Template
- Defined in:
- lib/vedeu/templating/template.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Generic class to loading a template and parsing it via ERb.
Direct Known Subclasses
Instance Attribute Summary collapse
- #object ⇒ Class readonly protected private
- #options ⇒ Hash readonly protected private
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(object, path, options = {}) ⇒ Vedeu::Templating::Template
constructor
private
Returns a new instance of Vedeu::Templating::Template.
- #load ⇒ String private private
- #parse ⇒ Vedeu::Views::Stream private
- #path ⇒ String private private
Constructor Details
#initialize(object, path, options = {}) ⇒ Vedeu::Templating::Template
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Vedeu::Templating::Template.
26 27 28 29 30 |
# File 'lib/vedeu/templating/template.rb', line 26 def initialize(object, path, = {}) @object = object @path = path.to_s @options = || {} end |
Instance Attribute Details
#object ⇒ Class (readonly, protected)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
41 42 43 |
# File 'lib/vedeu/templating/template.rb', line 41 def object @object end |
#options ⇒ Hash (readonly, protected)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
45 46 47 |
# File 'lib/vedeu/templating/template.rb', line 45 def @options end |
Class Method Details
.parse(object, path, options = {}) ⇒ Vedeu::Views::Stream
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
15 16 17 |
# File 'lib/vedeu/templating/template.rb', line 15 def self.parse(object, path, = {}) new(object, path, ).parse end |
Instance Method Details
#load ⇒ String (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
50 51 52 |
# File 'lib/vedeu/templating/template.rb', line 50 def load File.read(path) end |
#parse ⇒ Vedeu::Views::Stream
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
33 34 35 |
# File 'lib/vedeu/templating/template.rb', line 33 def parse ERB.new(load, nil, '-').result(binding) end |
#path ⇒ String (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/vedeu/templating/template.rb', line 56 def path raise Vedeu::Error::MissingRequired, 'No path to template specified.' if @path.empty? unless File.exist?(@path) raise Vedeu::Error::MissingRequired, "Template file cannot be found. (#{@path})" end @path end |