Class: Wright::DSL::Util

Inherits:
Object
  • Object
show all
Defined in:
lib/wright/dsl.rb

Overview

DSL helper class.

Instance Method Summary collapse

Instance Method Details

#render_erb(template, hash) ⇒ String

Renders an ERB template using the supplied hash.

Parameters:

  • template (String)

    the template

  • hash (Hash)

    the hash

Returns:

  • (String)

    the rendered template



39
40
41
# File 'lib/wright/dsl.rb', line 39

def render_erb(template, hash)
  Wright::Util::ErbRenderer.new(hash).render(template)
end

#render_file(filename, hash) ⇒ String

Renders a template file according to the file’s extension using the supplied hash. Currently supports ERB (.erb) and Mustache (.mustache).

Parameters:

  • filename (String)

    the filename of the template file

  • hash (Hash)

    the hash

Returns:

  • (String)

    the rendered template



58
59
60
# File 'lib/wright/dsl.rb', line 58

def render_file(filename, hash)
  Wright::Util::FileRenderer.new(hash).render(filename)
end

#render_mustache(template, hash) ⇒ String

Renders a mustache template using the supplied hash.

Parameters:

  • template (String)

    the template

  • hash (Hash)

    the hash

Returns:

  • (String)

    the rendered template



47
48
49
# File 'lib/wright/dsl.rb', line 47

def render_mustache(template, hash)
  Wright::Util::MustacheRenderer.new(hash).render(template)
end