Class: Gumdrop::Renderer

Inherits:
Object
  • Object
show all
Includes:
Util::SiteAccess
Defined in:
lib/gumdrop/renderer.rb

Constant Summary collapse

SPECIAL_OPTS =
%w(layout force_partial)

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Util::SiteAccess

#parent, #site

Methods included from Util::Loggable

#log

Methods included from Util::Eventable

#clear_events, #event_block, #fire

Constructor Details

#initializeRenderer

Returns a new instance of Renderer.



10
11
12
13
14
15
# File 'lib/gumdrop/renderer.rb', line 10

def initialize
  site.active_renderer= self
  @context, @content, @opts= nil, nil, nil
  @ctx_pool= ContextPool.new self
  @cache= {}
end

Instance Attribute Details

#cacheObject (readonly)

Returns the value of attribute cache.



8
9
10
# File 'lib/gumdrop/renderer.rb', line 8

def cache
  @cache
end

#contextObject (readonly)

Returns the value of attribute context.



8
9
10
# File 'lib/gumdrop/renderer.rb', line 8

def context
  @context
end

#ctx_poolObject (readonly)

Returns the value of attribute ctx_pool.



8
9
10
# File 'lib/gumdrop/renderer.rb', line 8

def ctx_pool
  @ctx_pool
end

Class Method Details

.for(ext) ⇒ Object

Returns the ‘Tilt::Template` for the given `ext` or nil



200
201
202
203
204
# File 'lib/gumdrop/renderer.rb', line 200

def for(ext)
  Tilt[ext] 
rescue LoadError # stupid tilt and redcarpet, they don't play well together!
  nil
end

Instance Method Details

#draw(content, opts = {}) ⇒ Object



17
18
19
20
21
22
23
24
25
# File 'lib/gumdrop/renderer.rb', line 17

def draw(content, opts={})
  if @ctx_pool.size > 0
    _start_rendering(content, opts)
  else
    event_block :render_item do |data|
      _start_rendering(content, opts, data)
    end
  end
end