class Wright::Util::PencilMustache
PencilMustache
class.
@example
pencil_mustache = Wright::Util::PencilMustache.new template = "foo is {{foo}}." hash = { foo: :bar } pencil_mustache.render(template, hash) # => "foo is bar."
Public Instance Methods
render(template, hash)
click to toggle source
Renders a Mustache template using the supplied hash. @param template [String] the template @param hash [Hash] the hash @return [String] the rendered template @todo Raise NameError if necessary. @todo Add support for triple whiskers.
# File lib/wright/util/pencil_mustache.rb, line 45 def render(template, hash) template.gsub(/{{.*?}}/, add_whiskers(hash)) end
Private Instance Methods
add_whiskers(doc)
click to toggle source
# File lib/wright/util/pencil_mustache.rb, line 51 def add_whiskers(doc) with_whiskers = {} doc.keys.each { |k| with_whiskers["{{#{k}}}"] = doc[k] } with_whiskers end