Class: Rndr::Template

Inherits:
Object
  • Object
show all
Defined in:
lib/rndr/template.rb

Overview

This class is used to handle the rendering of ERB templates.

Author:

Instance Method Summary collapse

Constructor Details

#initialize(path:, vars: {}) ⇒ Template

Constructs a new instance of Template.

Parameters:

  • path (String)

    The path to the template file.

  • vars (Hash) (defaults to: {})

    A hash of the variables to be passed to the template's binding.



12
13
14
15
# File 'lib/rndr/template.rb', line 12

def initialize(path:, vars: {})
  @path = File.absolute_path(path)
  @vars = vars
end

Instance Method Details

#render(render_path) ⇒ Boolean

Renders the template to the supplied path.

Parameters:

  • render_path (String)

    Path to desired rendered template location.

Returns:

  • (Boolean)

    True if template was rendered successfully.



26
27
28
# File 'lib/rndr/template.rb', line 26

def render(render_path)
  render_helper(render_path)
end

#render?Boolean

Verifies if a template is renderable or not.

Returns:

  • (Boolean)

    True if template is renderable.



19
20
21
# File 'lib/rndr/template.rb', line 19

def render?
  render_helper
end