1
0
postdoc/lib/handlebars_renderer.rb
2020-12-06 21:05:11 +01:00

18 lines
371 B
Ruby

class HandlebarsRenderer
attr_reader :handlebars
def initialize
@handlebars = Handlebars::Handlebars.new
end
def render(template_string, bindings)
template = handlebars.compile(sanitize_template(template_string))
template.call(bindings)
end
private
def sanitize_template(template_string)
template_string.gsub('{{# if', '{{#if')
end
end