Class: Docks::Renderers::Slim

Inherits:
Base
  • Object
show all
Includes:
Common::Capturable, Common::Helperable
Defined in:
lib/docks/renderers/slim_renderer.rb

Instance Method Summary collapse

Methods included from Common::Capturable

#concat, #content_for, #content_for?

Methods included from Common::Helperable

#helpers

Methods inherited from Base

#ivars=

Constructor Details

#initializeSlim

Returns a new instance of Slim.



11
12
13
14
# File 'lib/docks/renderers/slim_renderer.rb', line 11

def initialize
  require "slim"
  super
end

Instance Method Details

#capture(*args) {|args| ... } ⇒ Object

Yields:

  • (args)


28
29
30
# File 'lib/docks/renderers/slim_renderer.rb', line 28

def capture(*args, &block)
  yield *args
end

#render(template, locals = {}) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/docks/renderers/slim_renderer.rb', line 16

def render(template, locals = {})
  content, layout, locals = normalize_content_and_locals(template, locals)
  return if content.nil?

  content = ::Slim::Template.new { content }.render(self, locals)
  return content if layout.nil?

  ::Slim::Template.new { layout }.render(self, locals) do |name|
    name.nil? ? content : @content_blocks[name]
  end
end