Class: Charming::Presentation::TemplateView
- Inherits:
-
View
- Object
- View
- Charming::Presentation::TemplateView
show all
- Defined in:
- lib/charming/presentation/template_view.rb
Instance Method Summary
collapse
Methods inherited from View
#focused?, #layout_assigns
Constructor Details
#initialize(template:, namespace: nil, **assigns) ⇒ TemplateView
Returns a new instance of TemplateView.
6
7
8
9
10
|
# File 'lib/charming/presentation/template_view.rb', line 6
def initialize(template:, namespace: nil, **assigns)
super(**assigns)
@template = template
@namespace = namespace
end
|
Instance Method Details
#render ⇒ Object
12
13
14
|
# File 'lib/charming/presentation/template_view.rb', line 12
def render
template.render(self).to_s
end
|
#template_binding ⇒ Object
16
17
18
19
20
|
# File 'lib/charming/presentation/template_view.rb', line 16
def template_binding
return binding unless namespace
namespace.module_eval("->(view) { view.instance_eval { binding } }", __FILE__, __LINE__).call(self)
end
|