Class: Stencil::If

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

Direct Known Subclasses

Else

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Block

#add, #ended, #initialize, #inspect, #parsed

Methods inherited from Directive

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

Constructor Details

This class inherits a constructor from Stencil::Block

Instance Attribute Details

#truthObject (readonly)

Returns the value of attribute truth.



261
262
263
# File 'lib/stencil/directives/base.rb', line 261

def truth
  @truth
end

Instance Method Details

#determine_truth(data) ⇒ Object



267
268
269
270
# File 'lib/stencil/directives/base.rb', line 267

def determine_truth(data)
  @truth = interpret(@code, data)
  return @truth
end

#inspect_argsObject



263
264
265
# File 'lib/stencil/directives/base.rb', line 263

def inspect_args
  @code
end

#render(state) ⇒ Object



272
273
274
275
276
# File 'lib/stencil/directives/base.rb', line 272

def render(state)
  if determine_truth(state.data)
    return super
  end
end

#setup_parameters(code) ⇒ Object



257
258
259
260
# File 'lib/stencil/directives/base.rb', line 257

def setup_parameters(code)
  @code = code
  @truth = nil
end