Class: Proforma::HtmlRenderer::Writer
- Inherits:
-
Object
- Object
- Proforma::HtmlRenderer::Writer
- Defined in:
- lib/proforma/html_renderer/writer.rb
Overview
This class can render ERB templates.
Defined Under Namespace
Classes: ErbBinding
Constant Summary collapse
- BACK_DIR =
'..'- ERB_OPTIONS =
'-'- TEMPLATE_DIR =
'templates'
Instance Method Summary collapse
-
#initialize(directory: nil, files: {}) ⇒ Writer
constructor
A new instance of Writer.
- #render(name, context = {}) ⇒ Object
Constructor Details
#initialize(directory: nil, files: {}) ⇒ Writer
Returns a new instance of Writer.
27 28 29 30 |
# File 'lib/proforma/html_renderer/writer.rb', line 27 def initialize(directory: nil, files: {}) @directory = directory || default_directory @files = to_erb_hash(files) end |
Instance Method Details
#render(name, context = {}) ⇒ Object
32 33 34 |
# File 'lib/proforma/html_renderer/writer.rb', line 32 def render(name, context = {}) erb_template(name).result(hash_to_binding(context)) end |