Class: Hanami::Mailer::Template Private

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

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

A logic-less template.

TODO this is identical to Hanami::View, consider to move into Hanami::Utils

Since:

  • 0.1.0

Instance Method Summary collapse

Constructor Details

#initialize(template, encoding = Encoding::UTF_8) ⇒ Template

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Template.

Since:

  • 0.1.0



14
15
16
# File 'lib/hanami/mailer/template.rb', line 14

def initialize(template, encoding = Encoding::UTF_8)
  @_template = Tilt.new(template, default_encoding: encoding)
end

Instance Method Details

#fileString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Get the path to the template

Returns:

  • (String)

    the pathname

Since:

  • 0.1.0



37
38
39
# File 'lib/hanami/mailer/template.rb', line 37

def file
  @_template.file
end

#render(scope = Object.new, locals = {}) ⇒ String

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Render the template within the context of the given scope.

Parameters:

  • scope (Class) (defaults to: Object.new)

    the rendering scope

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

    set of objects passed to the constructor

Returns:

  • (String)

    the output of the rendering process

Since:

  • 0.1.0



27
28
29
# File 'lib/hanami/mailer/template.rb', line 27

def render(scope = Object.new, locals = {})
  @_template.render(scope, locals)
end