Class: ErbTemplateRenderer
- Inherits:
-
Object
- Object
- ErbTemplateRenderer
- Defined in:
- lib/devlogs/render/erb_template_renderer.rb
Overview
ErbTemplateRenderer is a base class for rendering arbitrary ERB templates.
Direct Known Subclasses
Constant Summary collapse
- TIME_FORMAT_TEXT_ENTRY =
"%m-%d-%Y %k:%M"
Instance Attribute Summary collapse
-
#time ⇒ Object
readonly
Returns the value of attribute time.
Instance Method Summary collapse
-
#get_binding ⇒ Object
rubocop:disable.
-
#initialize(template_file_path) ⇒ ErbTemplateRenderer
constructor
A new instance of ErbTemplateRenderer.
-
#render ⇒ Object
Runs the ERB rendering using the provided template file template_file_path.
Constructor Details
#initialize(template_file_path) ⇒ ErbTemplateRenderer
Returns a new instance of ErbTemplateRenderer.
14 15 16 17 |
# File 'lib/devlogs/render/erb_template_renderer.rb', line 14 def initialize(template_file_path) @time = Time.new.strftime(TIME_FORMAT_TEXT_ENTRY) @template_file_path = template_file_path end |
Instance Attribute Details
#time ⇒ Object (readonly)
Returns the value of attribute time.
10 11 12 |
# File 'lib/devlogs/render/erb_template_renderer.rb', line 10 def time @time end |
Instance Method Details
#get_binding ⇒ Object
rubocop:disable
For ERB
33 34 35 |
# File 'lib/devlogs/render/erb_template_renderer.rb', line 33 def get_binding binding end |
#render ⇒ Object
Runs the ERB rendering using the provided template file template_file_path
24 25 26 27 |
# File 'lib/devlogs/render/erb_template_renderer.rb', line 24 def render erb = ERB.new(File.read(@template_file_path)) erb.result(get_binding) end |