Class: Tumblargh::Renderer::Blocks::Base

Inherits:
Tumblargh::Renderer::Base show all
Defined in:
lib/tumblargh/renderer/blocks/base.rb

Class Attribute Summary collapse

Attributes inherited from Tumblargh::Renderer::Base

#context, #node, #options

Instance Method Summary collapse

Methods inherited from Tumblargh::Renderer::Base

#context_post, contextual_tag, #escape_html, #escape_url, #initialize, #method_missing, #strip_html

Constructor Details

This class inherits a constructor from Tumblargh::Renderer::Base

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Tumblargh::Renderer::Base

Class Attribute Details

.should_render_ifObject

Returns the value of attribute should_render_if.



7
8
9
# File 'lib/tumblargh/renderer/blocks/base.rb', line 7

def should_render_if
  @should_render_if
end

Instance Method Details

#renderObject



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/tumblargh/renderer/blocks/base.rb', line 21

def render
  return '' unless should_render?

  _, type, options, *nodes = node

  res = nodes.map do |n|
    renderer = Renderer.factory(n, self, options)
    renderer.render unless renderer.nil?
  end

  " #{ res.join('') } "
end

#should_render?Boolean

Returns:



12
13
14
15
16
17
18
19
# File 'lib/tumblargh/renderer/blocks/base.rb', line 12

def should_render?
  if defined?(@should_render_if)
    val = send(@should_render_if)
    return !(val || val.nil? || (val.respond_to?(:blank?) ? val.blank? : val.empty?))
  end

  true
end