Class: RakeGitCrypt::Template
- Inherits:
-
Object
- Object
- RakeGitCrypt::Template
- Defined in:
- lib/rake_git_crypt/template.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(contents) ⇒ Template
constructor
A new instance of Template.
- #render(parameters = {}) ⇒ Object
Constructor Details
#initialize(contents) ⇒ Template
Returns a new instance of Template.
11 12 13 |
# File 'lib/rake_git_crypt/template.rb', line 11 def initialize(contents) @contents = contents end |
Class Method Details
.from_file(path) ⇒ Object
7 8 9 |
# File 'lib/rake_git_crypt/template.rb', line 7 def self.from_file(path) new(File.read(path)) end |
Instance Method Details
#render(parameters = {}) ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/rake_git_crypt/template.rb', line 15 def render(parameters = {}) context = Object.new parameters.each do |key, value| context.instance_variable_set("@#{key}", value) end context_binding = context.instance_eval { binding } ERB.new(@contents).result(context_binding) end |