Class: FunApi::ScopedTemplates

Inherits:
Object
  • Object
show all
Defined in:
lib/funapi/templates.rb

Instance Method Summary collapse

Constructor Details

#initialize(templates, layout) ⇒ ScopedTemplates

Returns a new instance of ScopedTemplates.



92
93
94
95
# File 'lib/funapi/templates.rb', line 92

def initialize(templates, layout)
  @templates = templates
  @layout = layout
end

Instance Method Details

#render(name, layout: nil, **context) ⇒ Object



97
98
99
100
# File 'lib/funapi/templates.rb', line 97

def render(name, layout: nil, **context)
  effective_layout = layout.nil? ? @layout : layout
  @templates.render(name, layout: effective_layout, **context)
end

#render_partial(name, **context) ⇒ Object



107
108
109
# File 'lib/funapi/templates.rb', line 107

def render_partial(name, **context)
  @templates.render_partial(name, **context)
end

#response(name, status: 200, headers: {}, layout: nil, **context) ⇒ Object



102
103
104
105
# File 'lib/funapi/templates.rb', line 102

def response(name, status: 200, headers: {}, layout: nil, **context)
  effective_layout = layout.nil? ? @layout : layout
  @templates.response(name, status: status, headers: headers, layout: effective_layout, **context)
end