Module: Sprinkle::Package::Rendering

Extended by:
ActiveSupport::Concern
Included in:
Package
Defined in:
lib/sprinkle/package/rendering.rb

Overview

For help on rendering, see the Sprinkle::Installers::FileInstaller.

Defined Under Namespace

Modules: Helpers

Instance Method Summary collapse

Instance Method Details

#render(filename, context = binding) ⇒ Object

read in filename and render it as ERB


23
24
25
26
# File 'lib/sprinkle/package/rendering.rb', line 23

def render(filename, context=binding)
  contents=File.read(expand_filename(filename))
  template(contents, context)
end

#template(src, context = binding) ⇒ Object

render src as ERB


15
16
17
18
19
20
# File 'lib/sprinkle/package/rendering.rb', line 15

def template(src, context=binding)
  eruby = Erubis::Eruby.new(src)
  eruby.result(context)
rescue Object => e
  raise Sprinkle::Errors::TemplateError.new(e, src, context)
end

#template_search_path(path) ⇒ Object

sets the path a package should use to search for templates


38
39
40
# File 'lib/sprinkle/package/rendering.rb', line 38

def template_search_path(path)
  @template_search_path = path
end