Class: Rager::Template::Providers::Mustache

Inherits:
Abstract
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/rager/template/providers/mustache.rb

Instance Method Summary collapse

Instance Method Details

#template(input, options) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/rager/template/providers/mustache.rb', line 16

def template(input, options)
  begin
    require "mustache"
  rescue LoadError
    raise Rager::Errors::DependencyError.new("mustache", details: "Please install the mustache gem to use mustache templates")
  end

  ::Mustache.render(input.template, input.variables)
rescue ::Mustache::Parser::SyntaxError, ::Mustache::ContextMiss => e
  raise Rager::Errors::TemplateError.new(input.template, input.variables, details: e.message)
end