Class: Stacco::Template::RenderContext

Inherits:
OpenStruct
  • Object
show all
Defined in:
lib/stacco.rb

Instance Method Summary collapse

Constructor Details

#initialize(stack, config, vars) ⇒ RenderContext

Returns a new instance of RenderContext.



346
347
348
349
350
# File 'lib/stacco.rb', line 346

def initialize(stack, config, vars)
  @stack = stack
  @config = config
  super(vars)
end

Instance Method Details

#j(str) ⇒ Object



352
353
354
# File 'lib/stacco.rb', line 352

def j(str)
  str.to_json
end

#ja(indent_n, lns) ⇒ Object



356
357
358
359
360
361
362
363
364
365
366
# File 'lib/stacco.rb', line 356

def ja(indent_n, lns)
  indent = " " * indent_n
  newline = "\n".to_json
  lns.map do |ln|
    if ln.chomp.empty?
      "%s \n" % [indent]
    else
      "%s%s, %s,\n" % [indent, ln.chomp.to_json, newline]
    end
  end.join[indent_n .. -3]
end