Class: ServerlessRedirector::Renderer
- Inherits:
-
Object
- Object
- ServerlessRedirector::Renderer
- Defined in:
- lib/serverless_redirector/renderer.rb
Constant Summary collapse
- BASE_PATH =
::File. '../../templates', File.dirname(__FILE__)
Instance Attribute Summary collapse
-
#template_name ⇒ Object
readonly
Returns the value of attribute template_name.
-
#template_path ⇒ Object
readonly
Returns the value of attribute template_path.
Instance Method Summary collapse
-
#initialize(template_name) ⇒ Renderer
constructor
A new instance of Renderer.
- #render(context = {}) ⇒ Object
Constructor Details
Instance Attribute Details
#template_name ⇒ Object (readonly)
Returns the value of attribute template_name.
9 10 11 |
# File 'lib/serverless_redirector/renderer.rb', line 9 def template_name @template_name end |
#template_path ⇒ Object (readonly)
Returns the value of attribute template_path.
9 10 11 |
# File 'lib/serverless_redirector/renderer.rb', line 9 def template_path @template_path end |
Instance Method Details
#render(context = {}) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/serverless_redirector/renderer.rb', line 16 def render(context = {}) contents = ::File.read(template_path) template = ERB.new contents ctx_binding = OpenStruct.new(context).instance_eval { binding } template.result ctx_binding end |