Class: Stencil::Else

Inherits:
If show all
Defined in:
lib/stencil/directives/base.rb

Instance Method Summary collapse

Methods inherited from If

#inspect_args, #render

Methods inherited from Block

#add, #ended, #initialize, #inspect, #render

Methods inherited from Directive

#checked_render, create, #initialize, #inspect, #inspect_args, #interpret, #postrender, #pre_end, #prerender, register, #render, #render_end

Constructor Details

This class inherits a constructor from Stencil::Block

Instance Method Details

#determine_truth(data) ⇒ Object



293
294
295
296
297
298
299
300
301
302
303
304
305
306
# File 'lib/stencil/directives/base.rb', line 293

def determine_truth(data)
  if @previous.truth
    @a_truth = true
    @truth = false
  else
    if @code.nil?
      @truth = true
    else
      @truth = interpret(@code, data)
    end
    @a_truth = @truth
  end
  @truth
end

#parsed(stack) ⇒ Object



308
309
310
311
312
313
314
315
# File 'lib/stencil/directives/base.rb', line 308

def parsed(stack)
  @previous = stack.last
  unless If === @previous 
    raise @source, "else has to follow if"
  end
  @previous.ended(stack)
  super
end

#setup_parameters(code) ⇒ Object



283
284
285
286
287
# File 'lib/stencil/directives/base.rb', line 283

def setup_parameters(code)
  super
  @previous = nil
  @a_truth = false
end

#truthObject



289
290
291
# File 'lib/stencil/directives/base.rb', line 289

def truth
  @a_truth
end