class TerraformTemplateRenderer::Binding

Provides a Binding context which we can add arbitrary params to (which will become instance variables for the templates when they get rendered). Also provides a method to render partial templates which will pass through itself as the binding context for the partial template

Public Class Methods

new(template_path) click to toggle source
# File lib/terraform_template_renderer/binding.rb, line 9
def initialize(template_path)
  @template_path = template_path
end

Public Instance Methods

add_param(key, value) click to toggle source
# File lib/terraform_template_renderer/binding.rb, line 13
def add_param(key, value)
  instance_variable_set("@#{key}", value)
end
bind() click to toggle source
# File lib/terraform_template_renderer/binding.rb, line 17
def bind
  binding
end
render(partial_path) click to toggle source
# File lib/terraform_template_renderer/binding.rb, line 21
def render(partial_path)
  path_to_partial = File.join(@template_path, partial_path)
  renderer = Renderer.new(File.read(path_to_partial), @template_path)

  renderer.render_with_binding(self)
end