Module: EasyType::Template

Defined in:
lib/easy_type/template.rb

Overview

Contains a template helper method.

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Object) included(parent)



8
9
10
# File 'lib/easy_type/template.rb', line 8

def self.included(parent)
  parent.extend(Template)
end

Instance Method Details

- (String) template(name, context)

This allows you to use an erb file. Just like in the normal Puppet classes. The file is searched in the template directory on the same level as the ruby library path. For most puppet classes this is eqal to the normal template path of a module

Examples:

template 'create_tablespace.sql', binding

Parameters:

  • name (String) —

    this is the name of the template to be used

  • context (Binding) —

    this is the binding to be used in the template

Returns:

  • (String) —

    interpreted ERB template

Raises:

  • (ArgumentError) —

    when the file doesn’t exist



26
27
28
29
30
# File 'lib/easy_type/template.rb', line 26

def template(name, context)
  full_name = get_erb_file(name)
  raise ArgumentError, "file #{name} not found" unless full_name
  ERB.new(IO.read(full_name)).result(context)
end