Class: Stacco::Template::RenderContext
- Inherits:
-
OpenStruct
- Object
- OpenStruct
- Stacco::Template::RenderContext
- Defined in:
- lib/stacco.rb
Instance Method Summary collapse
-
#initialize(stack, config, vars) ⇒ RenderContext
constructor
A new instance of RenderContext.
- #j(str) ⇒ Object
- #ja(indent_n, lns) ⇒ Object
Constructor Details
#initialize(stack, config, vars) ⇒ RenderContext
Returns a new instance of RenderContext.
350 351 352 353 354 |
# File 'lib/stacco.rb', line 350 def initialize(stack, config, vars) @stack = stack @config = config super(vars) end |
Instance Method Details
#j(str) ⇒ Object
356 357 358 |
# File 'lib/stacco.rb', line 356 def j(str) str.to_json end |
#ja(indent_n, lns) ⇒ Object
360 361 362 363 364 365 366 367 368 369 370 |
# File 'lib/stacco.rb', line 360 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 |