Module: Ramaze::View::Slippers

Defined in:
lib/ramaze/view/slippers.rb

Overview

View adapter for Slippers, see the website of Slippers for more information: http://starapor.github.com/slippers/

Class Method Summary (collapse)

Class Method Details

+ (Object) call(action, string)



11
12
13
14
15
16
17
18
19
20
# File 'lib/ramaze/view/slippers.rb', line 11

def self.call(action, string)
  slippers = View.compile(string) do |s|
    ::Slippers::Engine.new(s, :template_group => template_group(action))
  end

  object_to_render = ::Slippers::BindingWrapper.new(action.instance.binding)
  html             = slippers.render(object_to_render)

  return html, 'text/html'
end

+ (Object) template_group(action) (private)



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/ramaze/view/slippers.rb', line 24

def self.template_group(action)
  subtemplates = action.instance.ancestral_trait[:slippers_options] || {}
  missing_template_handler = action.instance.ancestral_trait[
    :slippers_missing_template_handler
  ]
  default_string = action.instance.ancestral_trait[
    :slippers_default_string
  ]

  views = action.instance.options[:views].map do |view|
    "#{action.instance.options[:roots]}/#{view}"
  end

  super_group = ::Slippers::TemplateGroup.new(
    :templates                => subtemplates,
    :missing_template_handler => missing_template_handler,
    :default_string           => default_string
  )

  ::Slippers::TemplateGroupDirectory.new(
    views, :super_group       => super_group,
    :missing_template_handler => missing_template_handler,
    :default_string           => default_string
  )
end