Class: Bosh::Director::Core::Templates::SourceErb
- Inherits:
-
Object
- Object
- Bosh::Director::Core::Templates::SourceErb
- Defined in:
- lib/bosh/director/core/templates/source_erb.rb
Instance Attribute Summary collapse
-
#dest_name ⇒ Object
readonly
Returns the value of attribute dest_name.
-
#erb ⇒ Object
readonly
Returns the value of attribute erb.
-
#src_name ⇒ Object
readonly
Returns the value of attribute src_name.
Instance Method Summary collapse
-
#initialize(src_name, dest_name, erb_contents, template_name) ⇒ SourceErb
constructor
A new instance of SourceErb.
- #render(context, logger) ⇒ Object
Constructor Details
#initialize(src_name, dest_name, erb_contents, template_name) ⇒ SourceErb
Returns a new instance of SourceErb.
8 9 10 11 12 13 14 |
# File 'lib/bosh/director/core/templates/source_erb.rb', line 8 def initialize(src_name, dest_name, erb_contents, template_name) @src_name = src_name @dest_name = dest_name erb = ERB.new(erb_contents) erb.filename = File.join(template_name, src_name) @erb = erb end |
Instance Attribute Details
#dest_name ⇒ Object (readonly)
Returns the value of attribute dest_name.
6 7 8 |
# File 'lib/bosh/director/core/templates/source_erb.rb', line 6 def dest_name @dest_name end |
#erb ⇒ Object (readonly)
Returns the value of attribute erb.
6 7 8 |
# File 'lib/bosh/director/core/templates/source_erb.rb', line 6 def erb @erb end |
#src_name ⇒ Object (readonly)
Returns the value of attribute src_name.
6 7 8 |
# File 'lib/bosh/director/core/templates/source_erb.rb', line 6 def src_name @src_name end |
Instance Method Details
#render(context, logger) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/bosh/director/core/templates/source_erb.rb', line 16 def render(context, logger) erb.result(context.get_binding) # rubocop:disable RescueException rescue Exception => e # rubocop:enable RescueException logger.debug(e.inspect) line_index = e.backtrace.index { |l| l.include?(erb.filename) } line = line_index ? e.backtrace[line_index] : '(unknown):(unknown)' template_name, line = line.split(':') = "Error filling in template '#{File.basename(template_name)}' (line #{line}: #{e})" logger.debug("#{}\n#{e.backtrace.join("\n")}") raise end |