Class: Souffle::Template

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

Overview

Template wrapper around the Tilt Template Abstraction Library.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(template) ⇒ Template

Creates a new template.

Parameters:

  • template (String)

    The name of the template to render.



10
11
12
13
# File 'lib/souffle/template.rb', line 10

def initialize(template)
  @template = Tilt.new(
    File.expand_path("#{Souffle::Template.template_path}/#{template}"))
end

Class Method Details

.template_pathString

Helper pointing to the default templates path.

Returns:

  • (String)

    The path to the Souffle templates.



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

def self.template_path
  File.expand_path(File.join(File.dirname(__FILE__), 'templates'))
end

Instance Method Details

#render(binding) ⇒ String

Renders the template with the given binding.

Parameters:

  • binding (Object)

    The binding object for the template.

Returns:

  • (String)

    The rendered template.



20
21
22
# File 'lib/souffle/template.rb', line 20

def render(binding)
  @template.render(binding)
end