Class: Terraspace::Compiler::Erb::Render

Inherits:
Object
  • Object
show all
Defined in:
lib/terraspace/compiler/erb/render.rb

Instance Method Summary collapse

Constructor Details

#initialize(mod, src_path) ⇒ Render

Returns a new instance of Render.



3
4
5
# File 'lib/terraspace/compiler/erb/render.rb', line 3

def initialize(mod, src_path)
  @mod, @src_path = mod, src_path
end

Instance Method Details

#buildObject



7
8
9
10
11
12
13
14
15
16
# File 'lib/terraspace/compiler/erb/render.rb', line 7

def build
  context = Context.new(@mod)
  if @mod.resolved
    RenderMePretty.result(@src_path, context: context)
  else
    # Replace contents so only the `output` and `depends_on` are evaluated
    temp_path = Rewrite.new(@src_path).rewrite
    RenderMePretty.result(temp_path, context: context)
  end
end