Class: Wright::Util::PencilMustache Private

Inherits:
Object
  • Object
show all
Defined in:
lib/wright/util/pencil_mustache.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.

PencilMustache class.

Examples:

pencil_mustache = Wright::Util::PencilMustache.new
template = "foo is {{foo}}."
hash = { foo: :bar }
pencil_mustache.render(template, hash)
# => "foo is bar."

Instance Method Summary collapse

Instance Method Details

#render(template, hash) ⇒ 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.

TODO:

Raise NameError if necessary.

TODO:

Add support for triple whiskers.

Renders a Mustache template using the supplied hash.

Parameters:

  • template (String)

    the template

  • hash (Hash)

    the hash

Returns:

  • (String)

    the rendered template



45
46
47
# File 'lib/wright/util/pencil_mustache.rb', line 45

def render(template, hash)
  template.gsub(/{{.*?}}/, add_whiskers(hash))
end