Class: DatabaseLoader::Template
- Inherits:
-
Object
- Object
- DatabaseLoader::Template
- Defined in:
- lib/database_loader/template.rb
Instance Attribute Summary collapse
-
#contents ⇒ Object
Returns the value of attribute contents.
Instance Method Summary collapse
-
#initialize(contents) ⇒ Template
constructor
A new instance of Template.
- #render(options = {}) ⇒ Object
Constructor Details
#initialize(contents) ⇒ Template
Returns a new instance of Template.
5 6 7 |
# File 'lib/database_loader/template.rb', line 5 def initialize(contents) self.contents = contents end |
Instance Attribute Details
#contents ⇒ Object
Returns the value of attribute contents.
3 4 5 |
# File 'lib/database_loader/template.rb', line 3 def contents @contents end |
Instance Method Details
#render(options = {}) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/database_loader/template.rb', line 9 def render( = {}) case DatabaseLoader.template_engine when :liquid require "liquid" Liquid::Template.parse(contents).render() when :erb require "erb" struct = OpenStruct.new() ERB.new(contents).result(struct.send(:binding)) when :erubis require "erubis" struct = OpenStruct.new() Erubis::Eruby.new(contents).result(struct.send(:binding)) else contents end end |